diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libatexit.tex | 9 | ||||
-rw-r--r-- | Doc/lib/libreadline.tex | 64 | ||||
-rw-r--r-- | Doc/lib/librlcompleter.tex | 10 |
3 files changed, 46 insertions, 37 deletions
diff --git a/Doc/lib/libatexit.tex b/Doc/lib/libatexit.tex index d06024b..a30c175 100644 --- a/Doc/lib/libatexit.tex +++ b/Doc/lib/libatexit.tex @@ -1,5 +1,5 @@ \section{\module{atexit} --- - exit handlers} + Exit handlers} \declaremodule{standard}{atexit} \moduleauthor{Skip Montanaro}{skip@mojam.com} @@ -14,7 +14,7 @@ executed upon normal interpreter termination. Note: the functions registered via this module are not called when the program is killed by a signal, when a Python fatal internal error is detected, or when -\code{os._exit()} is called. +\function{os._exit()} is called. This is an alternate interface to the functionality provided by the \code{sys.exitfunc} variable. @@ -67,7 +67,8 @@ import atexit atexit.register(savecounter) \end{verbatim} + \begin{seealso} - \seemodule{readline}{useful example of atexit to read and write readline - history files} + \seemodule{readline}{Useful example of atexit to read and write + \refmodule{readline} history files.} \end{seealso} diff --git a/Doc/lib/libreadline.tex b/Doc/lib/libreadline.tex index 1b92d57..7c5683f 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} diff --git a/Doc/lib/librlcompleter.tex b/Doc/lib/librlcompleter.tex index 74b0c78..c0c4db8 100644 --- a/Doc/lib/librlcompleter.tex +++ b/Doc/lib/librlcompleter.tex @@ -2,12 +2,16 @@ Completion function for readline} \declaremodule{standard}{rlcompleter} + \platform{Unix} \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Python identifier completion in the readline library.} The \module{rlcompleter} module defines a completion function for -the \module{readline} module by completing valid Python identifiers and -keyword. +the \refmodule{readline} module by completing valid Python identifiers +and keywords. + +This module is \UNIX-specific due to it's dependence on the +\refmodule{readline} module. The \module{rlcompleter} module defines the \class{Completer} class. @@ -47,7 +51,7 @@ Completer objects have the following method: \begin{methoddesc}[Completer]{complete}{text, state} Return the \var{state}th completion for \var{text}. -If called for \var{text} that doesn't includea period character +If called for \var{text} that doesn't include a period character (\character{.}), it will complete from names currently defined in \refmodule[main]{__main__}, \refmodule[builtin]{__builtin__} and keywords (as defined by the \refmodule{keyword} module). |