Clearing pythonwin environment
steven.bethard at gmail.com
Fri Jun 23 19:08:38 CEST 2006
Network Ninja wrote:
> I want to restart the environment occasionally to default (like I
> restarted pythonwin). I wrote this script. I know why it doesn't work,
> cause it deletes my variable (item) on each iteration. My question is:
> is it possible to do this? What other things might I try?
> # Reset Pythonwin enviroment
> # Variables
> keep = ['__builtins__', '__doc__', '__name__', 'pywin', 'keep', 'item']
> for item in dir():
> if item not in keep:
> del item
I believe that should work.
Note that this won't cause imported modules to be reloaded though, so I
wouldn't rely on it too heavily. The imported modules problem can only
really be solved by restarting the interpreter.
More information about the Python-list