I\'m writing a command-line interface in Python. It uses the readline module to provide command history and completion.
While everything works fine in interactive mode,
rlcompleter might accomplish what you want
From the documentation:
The rlcompleter module is designed for use with Python’s interactive mode. A user can add the following lines to his or her initialization file (identified by the PYTHONSTARTUP environment variable) to get automatic Tab completion:
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
https://docs.python.org/2/library/rlcompleter.html