[Python-3000] The meaning of "global variable"

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Nov 4 01:57:58 CET 2006


Ron Adam wrote:

> How about limiting nonlocal to just the immediate parent scope and using 
> 'parent' as the keyword?

That could lead to confusing situations. What should
the following do:

   def f():
     x = 42
     def g():
       def h():
       parent x
       x = 88

Should the assignment to x in h() create a name in
the scope of g() even though there's no assignment
in g() to establish that as its home scope? Should
it be an error?

--
Greg


More information about the Python-3000 mailing list