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 holdenweb
Recipients holdenweb
Date 2014-07-02.11:54:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1404302050.04.0.0402916465626.issue21904@psf.upfronthosting.co.za>
In-reply-to
Content
When repeated use of a nonlocal variable is made (e.g. to define multiple functions in a loop) ideally the closure should reflect the value of the local variable at the time of use. This should at least be explicitly documented if the behavior is considered not to be a bug.

The code sample attached shows that the closures produced operate differently inside and outside the enclosing function.

Without an explicit nonlocal declaration the closure should not be able to affect the nonlocal variable's value (which anyway hardly makes sense once the enclosing namespace has been destroyed), so I think it's possible to argue that this behavior is a bug, but I'd value comments from experienced developers.
History
Date User Action Args
2014-07-02 11:54:10holdenwebsetrecipients: + holdenweb
2014-07-02 11:54:10holdenwebsetmessageid: <1404302050.04.0.0402916465626.issue21904@psf.upfronthosting.co.za>
2014-07-02 11:54:09holdenweblinkissue21904 messages
2014-07-02 11:54:09holdenwebcreate