Reloading modules into interpreter
Stefan Schwarzer
s.schwarzer at ndh.net
Sat Aug 11 18:59:44 EDT 2001
Hello Joe
jsnyder schrieb:
> Hello, I'm a newbie at Python and the solution to the following seems to
> escape me at the moment:
>
> Running from Pythonwin, I am importing a module and then calling its method.
> Then I change the module code and run it again, but the old code still runs,
> not the new code. The only way I have been able to get the new code is to
> shut down the interpreter, restart it and reimport the module. Surely there
> is an easier way.
You may use
reload(module)
if you earlier did
import module
However, that would cause problems if some code had changed the module's
contents and relies on them.
Therefore, I use reload only for tests in the interactive interpreter.
Stefan
More information about the Python-list
mailing list