1

I am testing code in the python interpreter and editing in a separate window. I currently need to restart python whenever I make a change to the module I am testing.

Is there an easier way to do this?

Thanks,

Charlie

  • Duplicate: "How do I unload (reload) a Python module?" http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module – Jason Coon May 04 '09 at 15:06

3 Answers3

10

The built-in function reload is what you're looking for.

avakar
  • 32,009
  • 9
  • 68
  • 103
3

It sounds like you want to reload the module, for which there is a built-in function reload(module). That said, when I looked it up just now (to make sure I had my reference right, Google returned a couple of discussions (granted they are several years old) pointing out problems using reload(). You might want to review those if reload() causes you headaches.

acrosman
  • 12,814
  • 10
  • 39
  • 55
1

Have a look at IPython http://ipython.scipy.org. It has various features that make working with Python code interactively easier.

Some screenshots and tips.

codeape
  • 97,830
  • 24
  • 159
  • 188