PEP 227 (was Re: Nested scopes resolution -- you can breathe again!)
Alex Martelli
aleaxit at yahoo.com
Thu Mar 1 10:46:36 EST 2001
"Jeremy Hylton" <jeremy at alum.mit.edu> wrote in message
news:mailman.983384008.21434.python-list at python.org...
[snip]
> Rebinding names in enclosing scopes
[snip]
> opposed to it. It is difficult to support, because it would
> require a new mechanism that would allow the programmer to specify
> that an assignment in a block is supposed to rebind the name in an
> enclosing block; presumably a keyword or special syntax (x := 3)
> would make this possible.
If this were to be allowed (and I'm not saying it should be!), the
most natural way to allow it would appear to be to be a new clause
on the global statement -- most natural, because "allow rebinding
in an outer scope" is exactly global's job (of course, up to Python
2, the only 'outer scope' was the module-one:-).
Maybe something like...:
def spam():
def inner():
global in spam, x
x += 1
x = 23
inner()
Alex
More information about the Python-list
mailing list