10
10
11
11
--------------
12
12
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 .
15
15
16
16
When this module is imported on a Unix platform with the :mod: `readline ` module
17
17
available, 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 >`.
19
21
20
22
Example::
21
23
@@ -28,7 +30,7 @@ Example::
28
30
readline.__name__ readline.parse_and_bind(
29
31
>>> readline.
30
32
31
- The :mod: `rlcompleter ` module is designed for use with Python's
33
+ The :mod: `! rlcompleter ` module is designed for use with Python's
32
34
:ref: `interactive mode <tut-interactive >`. Unless Python is run with the
33
35
:option: `-S ` option, the module is automatically imported and configured
34
36
(see :ref: `rlcompleter-config `).
@@ -39,23 +41,25 @@ this module can still be used for custom purposes.
39
41
40
42
.. _completer-objects :
41
43
42
- Completer Objects
43
- -----------------
44
+ .. class :: Completer
44
45
45
- Completer objects have the following method:
46
+ Completer objects have the following method:
46
47
48
+ .. method :: Completer.complete(text, state)
47
49
48
- .. method :: Completer.complete(text, state)
50
+ Return the next possible completion for * text *.
49
51
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 ``.
51
55
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).
61
59
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