[Python-3000] Draft PEP for outer scopes
Ka-Ping Yee
python at zesty.ca
Mon Nov 6 06:16:37 CET 2006
On Sat, 4 Nov 2006, Nick Coghlan wrote:
> Count me as another +1 on disallowing the shorthand version.
>
> Rationale:
> 1. We've lived without it in the case of global
> 2. We can add it later if we decide we really need it, but if we
> start with it and it turns out to be confusing or error-prone,
> taking it away would be a serious pain.
That's a good point. We can start without it, or perhaps with just
the simple form that Guido said he'd endorse, and find out later if
people want to be able to do the other forms of assignment.
> 3. Leaving it out ducks some hard questions like "what does this do?":
>
> def weird(local=True):
> if local:
> n = 1 # Does this alter the closure variable?
> else:
> nonlocal n += i
> return n
Maybe this will confuse people, maybe it won't. I think we do know
that so far the possibility of writing:
def weird(local=True):
if local:
n = 1
else:
global n
n += 1
return n
doesn't seem to have caused problems. I can see how the shorthand
form makes it more likely that people will want to put "global" in
the middle of the function than at the beginning, though.
-- ?!ng
More information about the Python-3000
mailing list