Re: Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Aahz
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() >

Re: Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Emile van Sebille
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

Re: Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Russell Warren
My tests were run in python 2.6.5. -- http://mail.python.org/mailman/listinfo/python-list

Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Russell Warren
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. In each test function below I have an x variable (so "x" is in the namespace of each test function). I also have a nested function in e