[Python-Dev] Unbinding a name referenced by an enclosing scope - error in documentation?

Benjamin Peterson benjamin at python.org
Sat Feb 26 23:36:12 CET 2011


2011/2/26 Greg Ewing <greg.ewing at canterbury.ac.nz>:
> From: Grigory Javadyan
>> ... def f():
>> ...     a = 42
>> ...     def g():
>> ...             nonlocal a
>> ...             del a
>> ...
>> SyntaxError: can not delete variable 'a' referenced in nested scope
>
> Is there a rational for this? It seems inconsistent -- if you can
> assign to names in outer scopes, you should be able to del them
> as well.

Notice that it's now been changed...


-- 
Regards,
Benjamin


More information about the Python-Dev mailing list