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 docs@python, ericp, r.david.murray
Date 2010-07-16.23:08:44
SpamBayes Score 0.005062427
Marked as misclassified No
Message-id <1279321726.22.0.176177214762.issue9274@psf.upfronthosting.co.za>
In-reply-to
Content
locals() does not give you a copy of the locals dictionary that you can modify and expect the values to affect the actual locals they were copied from.  This is documented:

http://docs.python.org/library/functions.html#locals

You would need to pass InteractiveInterpreter the "real" locals dict from the frame to make your code work, and it sounds like you've already done this.  However, I don't believe that this is going to work in the general case (eg: in the face of nested scopes), which is why locals() is not updatable. The use case for InteractiveInterpreter is implementing a python-command-line-like utility, and thus has no need to update the locals in the current function.

A doc note about this in InteractiveInterpreter along the lines of the one in the 'exec' docs is almost certainly appropriate, so I'll leave this open as a doc bug.
History
Date User Action Args
2010-07-16 23:08:46r.david.murraysetrecipients: + r.david.murray, ericp, docs@python
2010-07-16 23:08:46r.david.murraysetmessageid: <1279321726.22.0.176177214762.issue9274@psf.upfronthosting.co.za>
2010-07-16 23:08:44r.david.murraylinkissue9274 messages
2010-07-16 23:08:44r.david.murraycreate