Thursday, May 5, 2011

How can I make a change to a module without restarting python interpreter?

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

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

  • 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.

  • 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.

0 comments:

Post a Comment