[Python-Dev] nonlocal x = value
Stefan Behnel
stefan_ml at behnel.de
Fri Dec 17 08:19:07 CET 2010
Hi,
it seems that Py3 doesn't support setting a "nonlocal" value as part of the
"nonlocal" command
Python 3.2a4+ (py3k:86480, Nov 16 2010, 16:43:22)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def x():
... y = 5
... def f():
... nonlocal y = 6
File "<stdin>", line 4
nonlocal y = 6
^
SyntaxError: invalid syntax
even though the PEP clearly describes this feature.
http://www.python.org/dev/peps/pep-3104/#proposed-solution
Either the PEP or the implementation should be updated. Personally, I think
the PEP should be changed as I think that the syntax complicates the
grammar more than it's worth. Also, the moratorium applies here, given that
Py3.1 does not implement this.
Comments?
Stefan
More information about the Python-Dev
mailing list