interactive shell -- reload definitions?

bruno at modulix onurb at xiludom.gro
Wed May 10 08:01:29 EDT 2006


Metalone wrote:
> I have a question about the interactive Python shell.  Is it possible
> to reload a file and get the new definitions.
> 
> For example, if I do
> import xyz
> 
> Then I find a bug in some function in xyz.
> So, I edit xyz.py
> 
> I would like to reload the definitions in xyz.py without leaving my
> current shell session.
> Is this possible?

you want reload().

> 
> Also, is there any way to save definitions created in the interactive
> shell to a file?
> Sometimes I write a simple function in the shell, and this wish I had
> that function in an external file.

AFAIK, Idle and IPython might do this.

I personnaly uses emacs + python-mode, and it's quite powerful (let you
eval a whole buffer or part of it in an running embedded python shell,
and of course copy/paste from the shell to a buffer).

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list