【发布时间】:2011-03-26 07:44:47
【问题描述】:
是否可以将现有 Python shell 中的 IPython shell 用作 shell-inside-a-shell,类似于内置的 code.interact()?
【问题讨论】:
是否可以将现有 Python shell 中的 IPython shell 用作 shell-inside-a-shell,类似于内置的 code.interact()?
【问题讨论】:
在 IPython 0.11 中对 API 进行了全面检查,并且 shell 更易于调用:
import IPython
IPython.embed()
【讨论】:
嵌入 IPython 的 recommended way 工作正常:
~ $ python
Python 2.7 [...]
>>> from IPython.Shell import IPShellEmbed
>>> ipshell = IPShellEmbed()
>>> ipshell()
In [1]:
【讨论】:
Django manage.py shell 尽可能调用 IPython shell,它的实现如下:
import IPython
shell = IPython.Shell.IPShell()
shell.mainloop()
【讨论】: