[Python-3000] Draft PEP for outer scopes

Fredrik Lundh fredrik at pythonware.com
Thu Nov 2 07:23:49 CET 2006


Guido van Rossum wrote:

>>  > A shorthand form is also permitted, in which nonlocal is prepended to
>>  > an assignment or augmented assignment statement:
>>  >
>>  >     nonlocal x = 3
>>
>> Is a similar statement for globals legal in Py3k? It's not in 2.4
>> (according to my own testing) or 2.5 (according to the grammar). The
>> syntax for 'global' and 'nonlocal' should be almost identical.
> 
> It's been proposed and I would endorse it.

except that the syntax looks like you're declaring *and* defining 
something in *this* scope, which isn't what's going on.

> My personal preference is still to abuse 'global' instead of adding a
> new, ugly keyword. That would make the syntax for global and nonlocal
> completely identical. :-) But I seem to be alone in this preference.

not necessarily, but that would rule it out for 2.X, I suppose.

</F>



More information about the Python-3000 mailing list