在标准 Python 交互式 shell 中,我可以按Ctrl+D关闭标准输入,它会显示输出:
$ python
Python 2.7.2 (default, Mar 7 2012, 21:18:58)
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> for f in range(5):
... print f (I press Enter here)
... (I press Ctrl+D here)
0
1
2
3
4
>>>
但是在 IPython 和 bpython 中,Ctrl+D不起作用,我必须按Enter两次才能得到结果:
IPython:
In [1]: for f in range(5):
...: print f (I press Enter here)
...: (I press Enter here)
...: (I press Enter here)
0
1
2
3
4
蟒蛇:
>>> for f in range(5):
... print f (I press Enter here)
... (I press Enter here)
... (I press Enter here)
0
1
2
3
4
我正在使用的版本:
[I] dev-python/ipython
Available versions: 0.10 0.10.1 0.10.2 ~0.12-r1 {doc emacs examples gnuplot matplotlib mongodb notebook qt4 readline (+)smp sqlite test wxwidgets}
Installed versions: 0.10.2(03:54:09 PM 08/12/2011)(examples readline -doc -emacs -gnuplot -smp -test -wxwidgets)
Homepage: http://ipython.org/
Description: Advanced interactive shell for Python
[I] dev-python/bpython
Available versions: 0.9.7.1 0.10.1 {gtk urwid}
Installed versions: 0.10.1(10:34:17 AM 03/14/2012)(gtk -urwid)
Homepage: http://www.bpython-interpreter.org/ https://bitbucket.org/bobf/bpython/ http://pypi.python.org/pypi/bpython
Description: Syntax highlighting and autocompletion for the Python interpreter