Runtime Data Attributes
function.__closure__
Closure cells in the order specified by co_freevars, or None when there are no cells. The attribute is read-only, but cells can be mutable.
Formal Syntax & Structure
python syntaxpython
f.__closure__Return Value
tuple | None
Value exposed by this attribute; availability and mutability depend on the owner as described.
Working Example
Example Snippetpython
def outer(): x = 7 def f(): return x return ff = outer()print(tuple(c.cell_contents for c in f.__closure__))