Apparently the code to forestall Tk eating events was too aggressive (Tk user input...
[python/dscho.git] / Doc / lib / librlcompleter.tex
blob03dea804d13a82444dfffd3b8adb13606d85ad74
1 \section{\module{rlcompleter} ---
2 Completion function for GNU readline}
4 \declaremodule{standard}{rlcompleter}
5 \platform{Unix}
6 \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
7 \modulesynopsis{Python identifier completion for the GNU readline library.}
9 The \module{rlcompleter} module defines a completion function for
10 the \refmodule{readline} module by completing valid Python identifiers
11 and keywords.
13 This module is \UNIX-specific due to it's dependence on the
14 \refmodule{readline} module.
16 The \module{rlcompleter} module defines the \class{Completer} class.
18 Example:
20 \begin{verbatim}
21 >>> import rlcompleter
22 >>> import readline
23 >>> readline.parse_and_bind("tab: complete")
24 >>> readline. <TAB PRESSED>
25 readline.__doc__ readline.get_line_buffer readline.read_init_file
26 readline.__file__ readline.insert_text readline.set_completer
27 readline.__name__ readline.parse_and_bind
28 >>> readline.
29 \end{verbatim}
31 The \module{rlcompleter} module is designed for use with Python's
32 interactive mode. A user can add the following lines to his or her
33 initialization file (identified by the \envvar{PYTHONSTARTUP}
34 environment variable) to get automatic \kbd{Tab} completion:
36 \begin{verbatim}
37 try:
38 import readline
39 except ImportError:
40 print "Module readline not available."
41 else:
42 import rlcompleter
43 readline.parse_and_bind("tab: complete")
44 \end{verbatim}
47 \subsection{Completer Objects \label{completer-objects}}
49 Completer objects have the following method:
51 \begin{methoddesc}[Completer]{complete}{text, state}
52 Return the \var{state}th completion for \var{text}.
54 If called for \var{text} that doesn't include a period character
55 (\character{.}), it will complete from names currently defined in
56 \refmodule[main]{__main__}, \refmodule[builtin]{__builtin__} and
57 keywords (as defined by the \refmodule{keyword} module).
59 If called for a dotted name, it will try to evaluate anything without
60 obvious side-effects (i.e., functions will not be evaluated, but it
61 can generate calls to \method{__getattr__()}) upto the last part, and
62 find matches for the rest via the \function{dir()} function.
63 \end{methoddesc}