Reloading modules into interpreter

Alex Martelli aleaxit at yahoo.com
Sat Aug 11 18:22:01 EDT 2001


"jsnyder" <jsnyder at trelis.com> wrote in message
news:9l48os$dg3$1 at slb6.atl.mindspring.net...
> 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.

Of course!  The fifth little iconic button from the left, with the tooltip
"Import/Reload" and the status message "Import/reload a Python
module", will open a file-selection box where you indicate your
Python source file; if that's the first time you're importing it, it
does an import, else, a reload (import is a Python statement, reload
a built-in function).

But there's more!  If when you click this toolbar-button the current
MDI child-window in Pythonwin is one with a module being edited,
you don't even have the bother of the file-selection box -- it knows
the module you want to import or reload is specifically the one
in the current MDI child-window.  Nice, isn't it?-)


Alex






More information about the Python-list mailing list