[BangPypers] Enclosing lexical context
Anand Balachandran Pillai
abpillai at gmail.com
Thu Apr 15 19:49:08 CEST 2010
On Thu, Apr 15, 2010 at 10:36 PM, Picachu Nioto <picachu.nioto at gmail.com>wrote:
> Could some one explain to me this sentence, I read in an example online
> "Python doesn't implement assignment of variables bound in an enclosing
> lexical context"
>>> def f(x):
... print a
>>> print a
In this case, the outer a is accessed automatically since we are using
indices and there is no local list "a", Python finds the scope from
the global scope and assigns correctly.
Looking at your code above, perhaps the 2nd explanation
makes it clear.
> BangPypers mailing list
> BangPypers at python.org
More information about the BangPypers