python interpreter

Jerry Hill malaclypse2 at gmail.com
Tue Aug 12 17:04:24 CEST 2008


On Tue, Aug 12, 2008 at 10:49 AM, Alexandru Mosoi <brtzsnr at gmail.com> wrote:
> I'm using python's interpreter's to run various commands (like a
> normal shell). However if sources are modified changes are not
> reflected so I have to restart interpreter. Is there any way to avoid
> restarting this?
>
> example:
> import blah

reload(blah)

Please see the documentation
(http://docs.python.org/lib/built-in-funcs.html) for reload, though.
There are lots of caveats to keep in mind.  In particular, reload does
not work if you import using the 'from ... import ...' construct, and
it doesn't do anything magical about existing instances of classes
that have now been redefined.  Using reload() can be a useful tool
when you are prototyping things and using them in the interactive
interpreter, but probably should not be relied on in production code.

-- 
Jerry



More information about the Python-list mailing list