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
12 The
\module{rlcompleter
} module defines the
\class{Completer
} class.
17 >>> import rlcompleter
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
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:
36 print "Module readline not available."
39 readline.parse_and_bind("tab: complete")
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.