Start a python interactive shell from python.

Fernando Perez fperez.net at gmail.com
Thu Jan 26 13:46:58 EST 2006


Bo Peng wrote:

> 
> I think I find what I need:
> 
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/355319

That's a nice, lightweight one.  Note that if you want to have all the bells
and whistles of ipython (and you have ipython already), then a simple

if __name__ == '__namin__':
    from IPython.Shell import IPShellEmbed
    ipshell = IPShellEmbed()
    ipshell() # this call anywhere in your program will start IPython 

will do.  You'll find all the details on how to customize ipython for this kind
of task here:

http://ipython.scipy.org/doc/manual/node9.html

Given ipython's threading capabilities, you can even instantiate this with
proper thread support in case you want to be able to use matplotlib (or any
other GUI toolkit) interactively. Neither the ASPN recipe, nor anything in the
stdlib, will give you this.

Feel free to stop by the ipython-user list if you have more questions: I don't
monitor c.l.py regularly so I may miss threads or replies here.

Cheers,

f




More information about the Python-list mailing list