19

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

4

3 回答 3

21

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

import IPython

IPython.embed()
于 2011-11-16T13:32:37.540 回答
3

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

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

In [1]: 
于 2010-10-14T01:22:03.933 回答
1

Djangomanage.py shell尽可能调用 IPython shell,它的实现如下:

import IPython

shell = IPython.Shell.IPShell()
shell.mainloop()
于 2010-08-06T12:33:50.147 回答