co_freevars question

Robert Brewer fumanchu at amor.org
Tue Apr 20 15:35:21 EDT 2004


Jeff Epler wrote:
> 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()

Ah...got it. Thanks!


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org




More information about the Python-list mailing list