使用Python shell中的IPython,如`code.interact()`

Ram*_*hum 16 python shell ipython

是否可以使用现有Python shell中的IPython shell作为shell-inside-a-shell,类似于内置code.interact()

yac*_*yac 19

IPython 0.11中,API已经过大修,shell更容易调用:

import IPython

IPython.embed()
Run Code Online (Sandbox Code Playgroud)


sna*_*hoe 3

推荐的嵌入 IPython 的方法效果很好:

~ $ python
Python 2.7 [...]
>>> from IPython.Shell import IPShellEmbed
>>> ipshell = IPShellEmbed()
>>> ipshell()

In [1]: 
Run Code Online (Sandbox Code Playgroud)