diff options
author | Fred Drake <fdrake@acm.org> | 2000-07-06 04:51:04 +0000 |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-07-06 04:51:04 +0000 |
commit | 0d3d08813126c30ab6a395cb4824fb5e0967392a (patch) | |
tree | f532f19fa316e29a13f938f2f4168662033bf08f /Doc/lib/libreadline.tex | |
parent | c593bc68ec42080bf90f2a79a05d40a096b29f8d (diff) | |
download | cpython-0d3d08813126c30ab6a395cb4824fb5e0967392a.tar.gz |
Several small changes, mostly to the markup, to improve consistency and
internal hyperlinking. Move some things around, also for consistency
with other modules ("See also" stuff tends to live at the \section level,
before sub-sections, etc.).
Diffstat (limited to 'Doc/lib/libreadline.tex')
-rw-r--r-- | Doc/lib/libreadline.tex | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/Doc/lib/libreadline.tex b/Doc/lib/libreadline.tex index 1b92d5741c..7c5683fea7 100644 --- a/Doc/lib/libreadline.tex +++ b/Doc/lib/libreadline.tex @@ -1,19 +1,20 @@ \section{\module{readline} --- - Expose GNU readline functionality to Python} + GNU readline interface} \declaremodule{builtin}{readline} + \platform{Unix} \sectionauthor{Skip Montanaro}{skip@mojam.com} - \modulesynopsis{GNU Readline in Python.} -\platform{UNIX} The \module{readline} module defines a number of functions used either -directly or from the \module{rlcompleter} module to facilitate completion -and history file read and write from the Python interpreter. +directly or from the \refmodule{rlcompleter} module to facilitate +completion and history file read and write from the Python +interpreter. The \module{readline} module defines the following functions: + \begin{funcdesc}{parse_and_bind}{string} Parse and execute single line of a readline init file. \end{funcdesc} @@ -33,19 +34,19 @@ The default filename is the last filename used. \begin{funcdesc}{read_history_file}{\optional{filename}} Load a readline history file. -The default filename is ~/.history. +The default filename is \file{\~{}/.history}. \end{funcdesc} \begin{funcdesc}{write_history_file}{\optional{filename}} Save a readline history file. -The default filename is ~/.history. +The default filename is \file{\~{}/.history}. \end{funcdesc} \begin{funcdesc}{set_completer}{\optional{function}} -Set or remove the completer function. -The function is called as function(text, state), +Set or remove the completer function. The completer function is +called as \code{\var{function}(\var{text}, \var{state})}, \code{for i in [0, 1, 2, ...]} until it returns a non-string. -It should return the next possible completion starting with 'text'. +It should return the next possible completion starting with \var{text}. \end{funcdesc} \begin{funcdesc}{get_begidx}{} @@ -64,27 +65,30 @@ Set the readline word delimiters for tab-completion. Get the readline word delimiters for tab-completion. \end{funcdesc} -\subsection{Example} -\nodename{Readline Example} -The following example demonstrates how to use the \module{readline} module's -history reading and writing functions to automatically load and save a -history file named \code{.pyhist} from the user's home directory. The code -below would normally be executed automatically during interactive sessions -from the user's PYTHONSTARTUP file. +\begin{seealso} + \seemodule{rlcompleter}{Completion of Python identifiers at the + interactive prompt.} +\end{seealso} + + +\subsection{Example \label{readline-example}} + +The following example demonstrates how to use the +\module{readline} module's history reading and writing functions to +automatically load and save a history file named \file{.pyhist} from +the user's home directory. The code below would normally be executed +automatically during interactive sessions from the user's +\envvar{PYTHONSTARTUP} file. \begin{verbatim} ->>> import os ->>> histfile = os.path.join(os.environ["HOME"], ".pyhist") ->>> try: ->>> readline.read_history_file(histfile) ->>> except IOError: ->>> pass ->>> import atexit ->>> atexit.register(readline.write_history_file, histfile) ->>> del os, histfile +import os +histfile = os.path.join(os.environ["HOME"], ".pyhist") +try: + readline.read_history_file(histfile) +except IOError: + pass +import atexit +atexit.register(readline.write_history_file, histfile) +del os, histfile \end{verbatim} - -\begin{seealso} - \seemodule{rlcompleter}{completion of Python identifiers} -\end{seealso} |