1 \section{\module{rlcompleter
} ---
2 Completion function for GNU readline
}
4 \declaremodule{standard
}{rlcompleter
}
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
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.
21 >>> import rlcompleter
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
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:
40 print "Module readline not available."
43 readline.parse_and_bind("tab: complete")
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.