1010
1111--------------
1212
13- The :mod: `rlcompleter ` module defines a completion function suitable for the
14- :mod: ` readline ` module by completing valid Python identifiers and keywords .
13+ The :mod: `! rlcompleter ` module defines a completion function suitable to be
14+ passed to :func: ` ~ readline.set_completer ` in the :mod: ` readline ` module .
1515
1616When this module is imported on a Unix platform with the :mod: `readline ` module
1717available, an instance of the :class: `Completer ` class is automatically created
18- and its :meth: `complete ` method is set as the :mod: `readline ` completer.
18+ and its :meth: `~Completer.complete ` method is set as the
19+ :ref: `readline completer <readline-completion >`. The method provides
20+ completion of valid Python :ref: `identifiers and keywords <identifiers >`.
1921
2022Example::
2123
@@ -28,7 +30,7 @@ Example::
2830 readline.__name__ readline.parse_and_bind(
2931 >>> readline.
3032
31- The :mod: `rlcompleter ` module is designed for use with Python's
33+ The :mod: `! rlcompleter ` module is designed for use with Python's
3234:ref: `interactive mode <tut-interactive >`. Unless Python is run with the
3335:option: `-S ` option, the module is automatically imported and configured
3436(see :ref: `rlcompleter-config `).
@@ -39,23 +41,25 @@ this module can still be used for custom purposes.
3941
4042.. _completer-objects :
4143
42- Completer Objects
43- -----------------
44+ .. class :: Completer
4445
45- Completer objects have the following method:
46+ Completer objects have the following method:
4647
48+ .. method :: Completer.complete(text, state)
4749
48- .. method :: Completer.complete(text, state)
50+ Return the next possible completion for * text *.
4951
50- Return the *state *\ th completion for *text *.
52+ When called by the :mod: `readline ` module, this method is called
53+ successively with ``state == 0, 1, 2, ... `` until the method returns
54+ ``None ``.
5155
52- If called for *text * that doesn't include a period character (``'.' ``), it will
53- complete from names currently defined in :mod: `__main__ `, :mod: `builtins ` and
54- keywords (as defined by the :mod: `keyword ` module).
55-
56- If called for a dotted name, it will try to evaluate anything without obvious
57- side-effects (functions will not be evaluated, but it can generate calls to
58- :meth: `__getattr__ `) up to the last part, and find matches for the rest via the
59- :func: `dir ` function. Any exception raised during the evaluation of the
60- expression is caught, silenced and :const: `None ` is returned.
56+ If called for *text * that doesn't include a period character (``'.' ``), it will
57+ complete from names currently defined in :mod: `__main__ `, :mod: `builtins ` and
58+ keywords (as defined by the :mod: `keyword ` module).
6159
60+ If called for a dotted name, it will try to evaluate anything without obvious
61+ side-effects (functions will not be evaluated, but it can generate calls to
62+ :meth: `~object.__getattr__ `) up to the last part, and find matches for the
63+ rest via the :func: `dir ` function. Any exception raised during the
64+ evaluation of the expression is caught, silenced and :const: `None ` is
65+ returned.
0 commit comments