how to re-import changed code?

Andrew Durdin adurdin at
Fri Oct 22 00:42:55 CEST 2004

On Sat, 16 Oct 2004 00:47:36 +0200, wolfgang.stoecher at
<wolfgang.stoecher at> wrote:
> Hi,
> another beginner's question:
> when I import a module, change the corresponding textfile and try to
> import the same module again, it looks like the internal code does not
> change (the source-line in an error-message is up to date, however!). Also
> del module before import and deleting the .pyc file do not help! How to
> realize a fast edit-try-cycle? (btw: I am using python 2.2 under windows)

You can use the reload() builtin:

>>> help(reload)
Help on built-in function reload:

    reload(module) -> module

    Reload the module.  The module must have been successfully imported before.

For example:

>>>import mymodule
>>># Change here

More information about the Python-list mailing list