forgetting state

Ken Seehof kseehof at neuralintegrator.com
Sun Mar 24 05:20:34 EST 2002


Some of the problems you may be running into can
be solved by using reload().  This is assuming
that your problems have to do with making changes
to your program between runs.

Also, avoid using    from mymodule import *
when mymodule.py is subject to change because
it will complicate your life somewhat.

Another trick is to put a reload in your modules:

  import foo
  reload(foo)
  import bar
  reload(bar)

Remember to remove the reloads before you ship!

If that doesn't help, launch your application
from outside the shell.  This is convienient if
you make an icon to launch your application.

I generally use the latter approach.  As far as
I know there isn't any good general solution to
all of the problems that occur when you rerun
programs from a python shell.


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Emerson Wood
> Sent: Saturday, March 23, 2002 3:40 PM
> To: python-list at python.org
> Subject: forgetting state
> 
> 
> Hi, how would I make a python interpreter
> shell forget everything that I've done
> and run a script or accepts commands as
> if it were first run?
> 
> The reason I ask is that I'm running
> on Windows, and using the IDLE which
> keeps a Python shell up all the time.
> It would be natural to use that shell
> to test my program, but I'm finding 
> problems running it twice.
> 
> -Emerson
> -- 
> http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list