[Python-Dev] nonlocal x = value

Alexander Belopolsky alexander.belopolsky at gmail.com
Fri Dec 17 19:00:53 CET 2010


On Fri, Dec 17, 2010 at 12:33 PM, Benjamin Peterson <benjamin at python.org> wrote:
..
>> Another +1 for the same reasons.  Also, since global does not allow
>> assignment, neither should nonlocal.
>
> Note that the PEP stated that global would also be extended.

I missed that, so for future reference, the PEP says:

"""
A shorthand form is also permitted, in which nonlocal is prepended to
an assignment or augmented assignment:

nonlocal x = 3
The above has exactly the same meaning as nonlocal x; x = 3. (Guido
supports a similar form of the global statement.)
"""

and refers to Guido's post at

http://mail.python.org/pipermail/python-3000/2006-November/004166.html

In any case, the relevant issue is

http://bugs.python.org/issue4199

and it should probably be marked as "after moratorium".  Meanwhile an
implementation status note can be added to the PEP to avoid this issue
being brought up again.


More information about the Python-Dev mailing list