ipython shortcut to reload modules

bernhard.voigt at gmail.com bernhard.voigt at gmail.com
Mon Feb 19 06:07:36 EST 2007


Hey!

I'm using ipython as my python shell and often run scripts with the
magic command %run:

In [1]: %run script.py

If modules are loaded within the script these are not reloaded when I
rerun the script. Hence, when I changed some of the modules loaded, I
have to call

In [2]: reload(module1)
Out [2]: <module 'module1' from ....
In [3]: reload(module2)
Out [3]: <module 'module2' from ...
In [4]: %run script.py

Is there a shortshut to reload the modules automatically before
rerunning the script?

In case of names imported from modules into the shell environment I
have to reload and re-import in order to have the changes available:

In [5]: from module1 import *
In [6]: reload(module1)
In [7]: from module1 import *

Is there a shortcut to force a reload of loaded modules and re-
defining the names loaded with from....import...?

Thanks! Bernhard




More information about the Python-list mailing list