Runtime Data Attributes
code.co_freevars
Names of closure variables referenced from enclosing function scopes, in cell-binding order. Global names are not free variables in this representation.
Formal Syntax & Structure
python syntaxpython
code.co_freevarsReturn Value
tuple[str, ...]
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(); code = f.__code__print(code.co_freevars)