This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients Camion, levkivskyi, r.david.murray, skrah
Date 2017-12-19.13:29:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513690190.34.0.213398074469.issue32361@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-12-19 13:29:50r.david.murraysetrecipients: + r.david.murray, skrah, levkivskyi, Camion
2017-12-19 13:29:50r.david.murraysetmessageid: <1513690190.34.0.213398074469.issue32361@psf.upfronthosting.co.za>
2017-12-19 13:29:50r.david.murraylinkissue32361 messages
2017-12-19 13:29:50r.david.murraycreate