We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

The rlcompleter module

(Optional, Unix only). This module provides word completion for the readline module.

To enable word completion, just import this module. By default, the completion function is bound to the ESCAPE key. Press ESCAPE twice to finish the current word. To change the key, you can use something like:

import readline
readline.parse_and_bind("tab: complete")

The following script shows how to use the completion functions from within a program.

Example: Using the rlcompleter module to expand names
# File: rlcompleter-example-1.py

import rlcompleter
import sys

completer = rlcompleter.Completer()

for phrase in "co", "sys.p", "is":
    print phrase, "=>",
    # emulate readline completion handler
        for index in xrange(sys.maxint):
            term = completer.complete(phrase, index)
            if term is None:
            print term,

co => continue compile complex coerce completer
sys.p => sys.path sys.platform sys.prefix
is => is isinstance issubclass