[docs] [issue24796] Deleting names referencing from enclosed and enclosing scopes

Steven D'Aprano report at bugs.python.org
Wed Aug 5 16:48:57 CEST 2015


Steven D'Aprano added the comment:

I wonder if it is a left-over from the behaviour prior to 3.2? In 3.1, I
get this syntax error:

py> def outer():
...     spam = 1
...     def inner():
...             nonlocal spam
...             del spam
...     inner()
...
SyntaxError: can not delete variable 'spam' referenced in nested scope

See also the "Changed in 3.2" comment here:

https://docs.python.org/3/reference/simple_stmts.html#the-del-statement

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24796>
_______________________________________


More information about the docs mailing list