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

I am testing the code in a python interpreter and editing it in a separate window. Currently I need to restart python whenever I make changes to a module that I am testing.

Is there an easier way to do this?

Thank,

Charlie

+1


source to share


3 answers


The built-in function reload

is what you are looking for.



+10


source


It sounds like you want to reload a module that has a built in reload (module) function . That said, when I looked at it right now (to make sure I have a link, Google returned a couple of discussions (assuming they are a few years old) pointing out problems with using reload (). You might want to consider them. if reload () is causing headaches.



+3


source


Have a look at IPython http://ipython.scipy.org . It has various features that make it easy to work with Python code.

Some screenshots and tips .

+1


source







All Articles