On 6/14/2010 9:33 PM, Steven D'Aprano wrote:
On Mon, 14 Jun 2010 20:46:28 -0700, John Nagle wrote:

So how can I detect a closure?

I *think* you do it through the co_flags attribute of the code object.
This is in Python 2.5:

although this doesn't seem to be documented, at least not here:

http://docs.python.org/reference/datamodel.html

   Got it. Check

        f.func_closure

for a non-null value.  For a closure, the value will be a Cell object.

The value of "func_closure" in f.func_globals is None, but that's the
wrong place to look, apparently.

                                John Nagle
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to