、自動補完を有効にするには、構文は少し異なっています。 (それは私が間違っていないよ場合readlineのであるとして) あなたは最初に入力してemacsのバインディングを強制することができます。
:
readline.parse_and_bind("bind -e")
は、その後、あなたは自動補完があなたのTABボタン(男性はeditrc)にリンクを追加することができます
readline.parse_and_bind("bind '\t' rl_complete")
そして、あなたはインデントサポートしたいと(インターネット上で見つかった)の歴史を持っている場合(私はミスを犯していない限り)、それはそのようになります。
import readline,rlcompleter
### Indenting
class TabCompleter(rlcompleter.Completer):
"""Completer that supports indenting"""
def complete(self, text, state):
if not text:
return (' ', None)[state]
else:
return rlcompleter.Completer.complete(self, text, state)
readline.set_completer(TabCompleter().complete)
### Add autocompletion
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind -e")
readline.parse_and_bind("bind '\t' rl_complete")
else:
readline.parse_and_bind("tab: complete")
### Add history
import os
histfile = os.path.join(os.environ["HOME"], ".pyhist")
try:
readline.read_history_file(histfile)
except IOError:
pass
import atexit
atexit.register(readline.write_history_file, histfile)
del histfile
以前にどのようなことをしましたか? –
ipythonやbpythonのようなものを使ってみましたか? –
まだ動作しない場合は、[別の投稿の私の回答](http://stackoverflow.com/questions/675370/tab-completion-in-python-interpreter-in-os-x-terminal/23908884#)を参照してください。 23908884)。 –