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: >>> def f(x): ... def g(): ... return x ... return g ... >>> >>> closure = f(42) >>> closure() 42 >>> closure.func_code.co_flags 19 >>> f.func_code.co_flags 3 although this doesn't seem to be documented, at least not here: http://docs.python.org/reference/datamodel.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list