interactive development in python
Oren Tirosh
oren-py-l at hishome.net
Wed Mar 12 03:27:09 EST 2003
On Tue, Mar 11, 2003 at 01:45:17PM -0800, Joseph Heled wrote:
> How do I re-load imported modules?
reload(module)
This re-executes the module body in the module namespace.
Some notes:
If you have imported any module functions or classes into your local
namespace they will still point to the old implementation.
Any instances you have created of classes in the module will remain
an instance of the old implementation. If the objects methods reference
module globals they will get the new implementation so you could get
a mixture of the old and new behavior.
Reloading does not clear the module namespace first. If globals were
added to the module they will not be cleared.
It does not reload other modules recursively.
With these caveats, it's still useful for a rapid edit-reload-test
cycles. I typically use:
>>> reload(mymodule); mymodule.sometest()
So I can just hit up-arrow+enter to see the effects.
Oren
More information about the Python-list
mailing list