On Mon, Jun 14, 2010 at 9:46 PM, John Nagle <na...@animats.com> wrote: > No indication there that "fbar" is a closure inside "foo". There > are "__closure__" and "__func_closure__" entries in there, but > they are both None. A non-closure function has the same entries. > > So how can I detect a closure?
Maybe because it has no non-local references, so it's not really a closure? >>> def foo(x): ... global fbar ... def bar(y): ... pass ... fbar = bar ... >>> foo(0) >>> fbar.func_closure >>> >>> def foo(x): ... global fbar ... def bar(y): ... x ... fbar = bar ... >>> foo(0) >>> fbar.func_closure (<cell at 0x7ffb7dbd8210: int object at 0xa9f2b0>,) Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list