Before upgrading to lion, I had tab complete working in a python shell via terminal. Following these instructions, it was possible to have tab complete working.
Sinc
As it uses libedit/editline, the syntax to enable autocompletion is a little bit different. You can first force emacs bindings (as it is with readline if I'm not wrong) by typing :
readline.parse_and_bind("bind -e")
Then you can add autocompletion linked to your TAB button (man editrc) :
readline.parse_and_bind("bind '\t' rl_complete")
And if you want to support indenting and has a history (found on internet), it should look like that (unless I made a mistake) :
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