0
我试图扩展python shell(我不能使用IPython,可悲)。我想能够完成关键字和解释一些自定义输入(这将不是有效的Python)。但是我无法使readline/rlcompleter和InteractiveConsole一起工作。为了演示这个问题:有没有什么办法可以在Python中结合readline/rlcompleter和InteractiveConsole?
$ python -c "import code; code.InteractiveConsole().interact()"
Python 2.7.10 (default, Jun 1 2015, 18:05:38)
[GCC 4.9.2] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import readline
>>> import rlcompleter
>>> readline.parse_and_bind("tab: complete")
>>> import string
>>> stri
这里点击标签什么都不做。
$ python
Python 2.7.10 (default, Jun 1 2015, 18:05:38)
[GCC 4.9.2] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline
>>> import rlcompleter
>>> readline.parse_and_bind("tab: complete")
>>> import string
>>> stri
点击标签现在完成“字符串”。
任何人都可以解释这是为什么,如果有解决方法?