In article ,
Russell Warren wrote:
>
>def test4():
>print "running test4..."
>x = 1
>def innerFunc():
>print "inner locals():",
>print "%s" % locals() # how is x in locals in this case??
>print x
>x = 2 #ONLY ADDED LINE TO TEST3
>innerFunc()
>
On 9/8/2010 2:18 PM Russell Warren said...
I'm having trouble understanding when variables are added to
namespaces. I thought I understood it, but my nested function
examples below have me very confused.
Take a look at PEP 227 where nested scopes are introduced.
http://www.python.org/dev/peps
My tests were run in python 2.6.5.
--
http://mail.python.org/mailman/listinfo/python-list