Cell objects and their values
Robert Brewer
fumanchu at amor.org
Wed Apr 21 19:06:41 EDT 2004
Say I obtain a cell object via:
>>> def f():
... y = 3
... def g():
... return y
... return g
...
>>> f().func_closure[0]
<cell at 0x011787F0: int object at 0x002F9320>
Is there a way to get the value of the int (f.y) which is referenced by
the cell, without inspecting (or even having a reference to) f? That is,
using only the object "g()" and its attributes, I'd like to obtain the
same value for LOAD_DEREF that the interpreter does; in the same way
that I can access g.func_globals, I'd like something similar to
"g.func_cellvars" (not just the names as in g.func_code.co_cellvars, but
the values)...
Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org
More information about the Python-list
mailing list