1. Nick Coghlan
  2. cpython_sandbox


cpython_sandbox / Doc / library / rlcompleter.rst

:mod:`rlcompleter` --- Completion function for GNU readline

Source code: :source:`Lib/rlcompleter.py`

The :mod:`rlcompleter` module defines a completion function suitable for the :mod:`readline` module by completing valid Python identifiers and keywords.

When this module is imported on a Unix platform with the :mod:`readline` module available, an instance of the :class:`Completer` class is automatically created and its :meth:`complete` method is set as the :mod:`readline` completer.


>>> import rlcompleter
>>> import readline
>>> readline.parse_and_bind("tab: complete")
>>> readline. <TAB PRESSED>
readline.__doc__          readline.get_line_buffer(  readline.read_init_file(
readline.__file__         readline.insert_text(      readline.set_completer(
readline.__name__         readline.parse_and_bind(
>>> readline.

The :mod:`rlcompleter` module is designed for use with Python's :ref:`interactive mode <tut-interactive>`. Unless Python is run with the :option:`-S` option, the module is automatically imported and configured (see :ref:`rlcompleter-config`).

On platforms without :mod:`readline`, the :class:`Completer` class defined by this module can still be used for custom purposes.

Completer Objects

Completer objects have the following method: