Xavier de Gaye added the comment: FWIW the definition of free variables can be found in the Language Reference at section 4.2.1. "Binding of names" [1]. The list of the free variables of a user defined function can be accessed through the __closure__ function attribute, a tuple. The function attributes are listed in the Language Reference at section 3.2. "The standard type hierarchy" [2]. In the example given at msg282236, the value of x would be printed by the statement: print(moo.__closure__[0].cell_contents) [1]https://docs.python.org/3/reference/executionmodel.html#naming-and-binding [2] https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarc... ---------- nosy: +xdegaye _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue28853> _______________________________________