Ditched '_find_SET()', since it was a no-value-added wrapper around
[python/dscho.git] / Doc / lib / librlcompleter.tex
blob74b0c78540ddf49720c4bc77dc1aa190ab4c8da8
1 \section{\module{rlcompleter} ---
2 Completion function for readline}
4 \declaremodule{standard}{rlcompleter}
5 \sectionauthor{Moshe Zadka}{mzadka@geocities.com}
6 \modulesynopsis{Python identifier completion in the readline library.}
8 The \module{rlcompleter} module defines a completion function for
9 the \module{readline} module by completing valid Python identifiers and
10 keyword.
12 The \module{rlcompleter} module defines the \class{Completer} class.
14 Example:
16 \begin{verbatim}
17 >>> import rlcompleter
18 >>> import readline
19 >>> readline.parse_and_bind("tab: complete")
20 >>> readline. <TAB PRESSED>
21 readline.__doc__ readline.get_line_buffer readline.read_init_file
22 readline.__file__ readline.insert_text readline.set_completer
23 readline.__name__ readline.parse_and_bind
24 >>> readline.
25 \end{verbatim}
27 The \module{rlcompleter} module is designed for use with Python's
28 interactive mode. A user can add the following lines to his or her
29 initialization file (identified by the \envvar{PYTHONSTARTUP}
30 environment variable) to get automatic \kbd{Tab} completion:
32 \begin{verbatim}
33 try:
34 import readline
35 except ImportError:
36 print "Module readline not available."
37 else:
38 import rlcompleter
39 readline.parse_and_bind("tab: complete")
40 \end{verbatim}
43 \subsection{Completer Objects \label{completer-objects}}
45 Completer objects have the following method:
47 \begin{methoddesc}[Completer]{complete}{text, state}
48 Return the \var{state}th completion for \var{text}.
50 If called for \var{text} that doesn't includea period character
51 (\character{.}), it will complete from names currently defined in
52 \refmodule[main]{__main__}, \refmodule[builtin]{__builtin__} and
53 keywords (as defined by the \refmodule{keyword} module).
55 If called for a dotted name, it will try to evaluate anything without
56 obvious side-effects (i.e., functions will not be evaluated, but it
57 can generate calls to \method{__getattr__()}) upto the last part, and
58 find matches for the rest via the \function{dir()} function.
59 \end{methoddesc}