Creating a cell 'by hand'
Jean-Paul Calderone
exarkun at divmod.com
Thu Nov 8 19:08:20 EST 2007
On Thu, 8 Nov 2007 18:30:15 -0500, "Prepscius, Colin \(IT\)" <colin.prepscius at morganstanley.com> wrote:
>The last argument to new.function takes a closure, which is a tuple of
>cell objects. Does anybody know how to create those cell objects 'by
>hand'?
Here's one approach:
>>> def f():
... x = 10
... def g():
... a = x
... return g
...
>>> f().func_closure
(<cell at 0xb7d47494: int object at 0x8141d44>,)
>>>
I don't know what your use-case is, so I have no idea if this is the
kind of solution you're looking for.
Jean-Paul
More information about the Python-list
mailing list