Using IPython from the Python shell like `code.interact()`
Is it possible to use the IPython she开发者_如何学运维ll from an existing Python shell, as a shell-inside-a-shell, similarly to the built-in code.interact()
?
In IPython 0.11 the API has been overhauled and the shell is even easier to invoke:
import IPython
IPython.embed()
The recommended way of embedding IPython works fine:
~ $ python
Python 2.7 [...]
>>> from IPython.Shell import IPShellEmbed
>>> ipshell = IPShellEmbed()
>>> ipshell()
In [1]:
Django manage.py shell
invoke a IPython shell when possible, and it's implemented like this:
import IPython
shell = IPython.Shell.IPShell()
shell.mainloop()
精彩评论