Reloading modules into interpreter

jsnyder trelis at mindspring.com
Sat Aug 11 18:46:57 EDT 2001


> > 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

Stefan,
That's exactly the answer I was hoping for.  Thank you!!

-Joe





More information about the Python-list mailing list