R. David Murray <rdmur...@bitdance.com> added the comment:

Right, it was indeed "designed that way" in the sense that nolocal was only 
ever intended to access variables from the surrounding local scope, *not* the 
global scope.  If you put a variable name in the global scope, nonlocal was not 
intended to be able to access it (it is then a global variable, not a local 
variable).

So the only question that keeps this issue open is can the error message be 
improved for the case where a global declaration affects the variable name in 
question (the message is clear when there is no variable with that name in the 
outer function at all).

Any change to this design would be an enhancement request and discussion of it 
should start on the python-ideas mailing list.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32361>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to