mirror of
https://github.com/python/cpython.git
synced 2025-08-18 07:41:05 +00:00

svn+ssh://pythondev@svn.python.org/python/trunk ........ r72558 | benjamin.peterson | 2009-05-11 01:52:09 +0200 (Mo, 11 Mai 2009) | 1 line sys.setdefaultencoding() strikes me as a bad example ........ r72745 | benjamin.peterson | 2009-05-17 16:16:29 +0200 (So, 17 Mai 2009) | 1 line ignore .rst files in sphinx its self ........ r72750 | benjamin.peterson | 2009-05-17 18:59:27 +0200 (So, 17 Mai 2009) | 1 line chop off slash ........ r72876 | benjamin.peterson | 2009-05-23 22:59:09 +0200 (Sa, 23 Mai 2009) | 1 line remove mention of old ctypes version ........ r73042 | benjamin.peterson | 2009-05-30 05:10:52 +0200 (Sa, 30 Mai 2009) | 1 line no fdatasync on macos ........ r73045 | georg.brandl | 2009-05-30 09:26:04 +0200 (Sa, 30 Mai 2009) | 1 line #6146: fix markup bug. ........ r73046 | georg.brandl | 2009-05-30 09:31:25 +0200 (Sa, 30 Mai 2009) | 1 line Use preferred form of raising exceptions. ........ r73047 | georg.brandl | 2009-05-30 12:33:23 +0200 (Sa, 30 Mai 2009) | 1 line Fix some more small markup problems. ........ r73048 | georg.brandl | 2009-05-30 12:34:25 +0200 (Sa, 30 Mai 2009) | 1 line Fix markup problem. ........ r73069 | benjamin.peterson | 2009-05-31 02:42:42 +0200 (So, 31 Mai 2009) | 1 line fix signature ........ r73089 | andrew.kuchling | 2009-06-01 02:14:19 +0200 (Mo, 01 Jun 2009) | 1 line The class for regexes isn't called RegexObject any more; correct the text ........ r73163 | georg.brandl | 2009-06-03 09:25:35 +0200 (Mi, 03 Jun 2009) | 1 line Use the preferred form of raise statements in the docs. ........ r73186 | georg.brandl | 2009-06-03 23:21:09 +0200 (Mi, 03 Jun 2009) | 1 line #6174: fix indentation in code example. ........ r73213 | georg.brandl | 2009-06-04 12:15:57 +0200 (Do, 04 Jun 2009) | 1 line #5967: note that the C slicing APIs do not support negative indices. ........ r73215 | georg.brandl | 2009-06-04 12:22:31 +0200 (Do, 04 Jun 2009) | 1 line #6176: fix man page section for flock(2). ........ r73217 | georg.brandl | 2009-06-04 12:27:21 +0200 (Do, 04 Jun 2009) | 1 line #6175: document that inet_aton supports alternate input formats with less than three dots. ........ r73257 | georg.brandl | 2009-06-06 19:50:05 +0200 (Sa, 06 Jun 2009) | 1 line #6211: elaborate a bit on ways to call the function. ........ r73258 | georg.brandl | 2009-06-06 19:51:31 +0200 (Sa, 06 Jun 2009) | 1 line #6204: use a real reference instead of "see later". ........ r73260 | georg.brandl | 2009-06-06 20:21:58 +0200 (Sa, 06 Jun 2009) | 1 line #6224: s/JPython/Jython/, and remove one link to a module nine years old. ........
66 lines
2.4 KiB
ReStructuredText
66 lines
2.4 KiB
ReStructuredText
|
|
:mod:`rlcompleter` --- Completion function for GNU readline
|
|
===========================================================
|
|
|
|
.. module:: rlcompleter
|
|
:synopsis: Python identifier completion, suitable for the GNU readline library.
|
|
.. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
|
|
|
|
|
|
The :mod:`rlcompleter` module defines a completion function suitable for the
|
|
:mod:`readline` module by completing valid Python identifiers and keywords.
|
|
|
|
When this module is imported on a Unix platform with the :mod:`readline` module
|
|
available, an instance of the :class:`Completer` class is automatically created
|
|
and its :meth:`complete` method is set as the :mod:`readline` completer.
|
|
|
|
Example::
|
|
|
|
>>> import rlcompleter
|
|
>>> import readline
|
|
>>> readline.parse_and_bind("tab: complete")
|
|
>>> readline. <TAB PRESSED>
|
|
readline.__doc__ readline.get_line_buffer( readline.read_init_file(
|
|
readline.__file__ readline.insert_text( readline.set_completer(
|
|
readline.__name__ readline.parse_and_bind(
|
|
>>> readline.
|
|
|
|
The :mod:`rlcompleter` module is designed for use with Python's interactive
|
|
mode. A user can add the following lines to his or her initialization file
|
|
(identified by the :envvar:`PYTHONSTARTUP` environment variable) to get
|
|
automatic :kbd:`Tab` completion::
|
|
|
|
try:
|
|
import readline
|
|
except ImportError:
|
|
print "Module readline not available."
|
|
else:
|
|
import rlcompleter
|
|
readline.parse_and_bind("tab: complete")
|
|
|
|
On platforms without :mod:`readline`, the :class:`Completer` class defined by
|
|
this module can still be used for custom purposes.
|
|
|
|
|
|
.. _completer-objects:
|
|
|
|
Completer Objects
|
|
-----------------
|
|
|
|
Completer objects have the following method:
|
|
|
|
|
|
.. method:: Completer.complete(text, state)
|
|
|
|
Return the *state*\ th completion for *text*.
|
|
|
|
If called for *text* that doesn't include a period character (``'.'``), it will
|
|
complete from names currently defined in :mod:`__main__`, :mod:`__builtin__` and
|
|
keywords (as defined by the :mod:`keyword` module).
|
|
|
|
If called for a dotted name, it will try to evaluate anything without obvious
|
|
side-effects (functions will not be evaluated, but it can generate calls to
|
|
:meth:`__getattr__`) up to the last part, and find matches for the rest via the
|
|
:func:`dir` function. Any exception raised during the evaluation of the
|
|
expression is caught, silenced and :const:`None` is returned.
|
|
|