Is access to locals() of "parent" namespace possible?
carsten at uniqsys.com
Fri Jul 27 23:01:29 CEST 2007
On Fri, 2007-07-27 at 20:46 +0000, André wrote:
> I want to give a user the possibility of "restarting" an interactive
> session, by removing all the objects defined by her since the
> beginning. The way I make this possible is by having a "function"
> that can be called during the interactive session using locals() as an
> argument, as follows:
> It works. However, I would like to make this "friendlier", i.e.
> requiring the user to simply type
> and have the code extract out the value of locals() of the "parent"
> namespace. I thought it might be possible using sys._getframe, but I
> have not been able to figure out why.
The same caveats for locals() apply here: Modifications to this
dictionary may or may not be visible to the caller.
More information about the Python-list