co_freevars names variables that come from an enclosing scope that is not module scope. def g(): return y print g.func_code.co_freevars # () def f(): y = 3 def g(): return y print g.func_code.co_freevars # ('y',) f() Jeff