rlcompleter – Adds tab-completion to the interactive interpreterΒΆ

Purpose:Adds tab-completion to the interactive interpreter
Available In:1.5 and later

rlcompleter adds tab-completion for Python symbols to the interactive interpreter. Importing the module causes it to configure a completer function for readline. The only other step required is to configure the tab key to trigger the completer. All of this can be done in a PYTHONSTARTUP file so that it runs each time the interactive interpreter starts.

For example, create a file ~/.pythonrc containing:

try:
    import readline
except ImportError:
    # Silently ignore missing readline module
    pass
else:
    import rlcompleter
    readline.parse_and_bind("tab: complete")

Then set PYTHONSTARTUP to "~/.pythonrc". When you start the interactive interpreter, tab completion for names from the contents of modules or attributes of objects is activated.

See also

rlcompleter
The standard library documentation for this module.
readline
The readline module.
Bookmark and Share