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

时间:2010-08-06 12:30:49

标签: python shell ipython

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

3 个答案:

答案 0 :(得分:19)

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

import IPython

IPython.embed()

答案 1 :(得分:3)

嵌入IPython的recommended way工作正常:

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

In [1]: 

答案 2 :(得分:1)

Django manage.py shell在可能的情况下调用IPython shell,它的实现如下:

import IPython

shell = IPython.Shell.IPShell()
shell.mainloop()
相关问题