diff options
author | Fred Drake <fdrake@acm.org> | 1998-02-13 06:58:54 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1998-02-13 06:58:54 (GMT) |
commit | 1947991c2f85db781fb3fcdc9e3bcfe2905e58e2 (patch) | |
tree | 260789493c7151408f009eaa84a7815ce4d28246 /Doc/lib | |
parent | dc8af0acc1fbeec89e43f1ea43bf1a4d016f4fc6 (diff) | |
download | cpython-1947991c2f85db781fb3fcdc9e3bcfe2905e58e2.zip cpython-1947991c2f85db781fb3fcdc9e3bcfe2905e58e2.tar.gz cpython-1947991c2f85db781fb3fcdc9e3bcfe2905e58e2.tar.bz2 |
Remove all \bcode / \ecode cruft; this is no longer needed. See previous
checkin of myformat.sty.
Change "\renewcommand{\indexsubitem}{(...)}" to "\setindexsubitem{(...)}"
everywhere.
Some other minor nits that I happened to come across.
Diffstat (limited to 'Doc/lib')
110 files changed, 469 insertions, 468 deletions
diff --git a/Doc/lib/libaifc.tex b/Doc/lib/libaifc.tex index 590f0d4..19af8f3 100644 --- a/Doc/lib/libaifc.tex +++ b/Doc/lib/libaifc.tex @@ -23,7 +23,7 @@ second's worth occupies 2*2*44100 bytes, i.e.\ 176,400 bytes. Module \code{aifc} defines the following function: -\renewcommand{\indexsubitem}{(in module aifc)} +\setindexsubitem{(in module aifc)} \begin{funcdesc}{open}{file\, mode} Open an AIFF or AIFF-C file and return an object instance with methods that are described below. The argument file is either a @@ -38,7 +38,7 @@ samples you are going to write in total and use Objects returned by \code{aifc.open()} when a file is opened for reading have the following methods: -\renewcommand{\indexsubitem}{(aifc object method)} +\setindexsubitem{(aifc object method)} \begin{funcdesc}{getnchannels}{} Return the number of audio channels (1 for mono, 2 for stereo). \end{funcdesc} diff --git a/Doc/lib/libal.tex b/Doc/lib/libal.tex index 5655be6..63bdf1b 100644 --- a/Doc/lib/libal.tex +++ b/Doc/lib/libal.tex @@ -25,7 +25,7 @@ documented upper limit.) The module defines the following functions: -\renewcommand{\indexsubitem}{(in module al)} +\setindexsubitem{(in module al)} \begin{funcdesc}{openport}{name\, direction\optional{\, config}} The name and direction arguments are strings. The optional config @@ -59,7 +59,7 @@ as returned by \code{al.queryparams}. Configuration objects (returned by \code{al.newconfig()} have the following methods: -\renewcommand{\indexsubitem}{(audio configuration object method)} +\setindexsubitem{(audio configuration object method)} \begin{funcdesc}{getqueuesize}{} Return the queue size. @@ -106,7 +106,7 @@ Set the maximum value for floating sample formats. Port objects (returned by \code{al.openport()} have the following methods: -\renewcommand{\indexsubitem}{(audio port object method)} +\setindexsubitem{(audio port object method)} \begin{funcdesc}{closeport}{} Close the port. @@ -167,7 +167,7 @@ the C header file \file{<audio.h>} except that the name prefix \samp{AL_} is omitted. Read the module source for a complete list of the defined names. Suggested use: -\bcode\begin{verbatim} +\begin{verbatim} import al from AL import * -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libamoeba.tex b/Doc/lib/libamoeba.tex index 747c5f3..10059ee 100644 --- a/Doc/lib/libamoeba.tex +++ b/Doc/lib/libamoeba.tex @@ -10,7 +10,7 @@ the exception \code{amoeba.error = 'amoeba.error'}. The module \code{amoeba} defines the following items: -\renewcommand{\indexsubitem}{(in module amoeba)} +\setindexsubitem{(in module amoeba)} \begin{funcdesc}{name_append}{path\, cap} Stores a capability in the Amoeba directory tree. Arguments are the pathname (a string) and the capability (a capability @@ -77,15 +77,15 @@ and \emph{a2c}(U). For example: -\bcode\begin{verbatim} +\begin{verbatim} >>> amoeba.name_lookup('/profile/cap') aa:1c:95:52:6a:fa/14(ff)/8e:ba:5b:8:11:1a >>> -\end{verbatim}\ecode +\end{verbatim} % The following methods are defined for capability objects. -\renewcommand{\indexsubitem}{(capability method)} +\setindexsubitem{(capability method)} \begin{funcdesc}{dir_list}{} Returns a list of the names of the entries in an Amoeba directory. \end{funcdesc} diff --git a/Doc/lib/libanydbm.tex b/Doc/lib/libanydbm.tex index b55b671..722d395 100644 --- a/Doc/lib/libanydbm.tex +++ b/Doc/lib/libanydbm.tex @@ -9,7 +9,7 @@ will be used. Both modules provide the same interface: % not the best solution, but it's what you get for documenting both % at the same time. -\renewcommand{\indexsubitem}{(in modules anydbm, dumbdbm)} +\setindexsubitem{(in modules anydbm, dumbdbm)} \begin{funcdesc}{open}{filename\optional{\, flag\, mode}} Open the database file \var{filename} and return a corresponding object. diff --git a/Doc/lib/libarray.tex b/Doc/lib/libarray.tex index 8490fc8..7ba3954 100644 --- a/Doc/lib/libarray.tex +++ b/Doc/lib/libarray.tex @@ -36,7 +36,7 @@ See also built-in module \code{struct}. The module defines the following function: -\renewcommand{\indexsubitem}{(in module array)} +\setindexsubitem{(in module array)} \begin{funcdesc}{array}{typecode\optional{\, initializer}} Return a new array whose items are restricted by \var{typecode}, and @@ -124,9 +124,9 @@ numbers. The string is guaranteed to be able to be converted back to an array with the same type and value using reverse quotes (\code{``}). Examples: -\bcode\begin{verbatim} +\begin{verbatim} array('l') array('c', 'hello world') array('l', [1, 2, 3, 4, 5]) array('d', [1.0, 2.0, 3.14]) -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libaudioop.tex b/Doc/lib/libaudioop.tex index b700155..69a3a83 100644 --- a/Doc/lib/libaudioop.tex +++ b/Doc/lib/libaudioop.tex @@ -13,7 +13,7 @@ otherwise the sample size (in bytes) is always a parameter of the operation. The module defines the following variables and functions: -\renewcommand{\indexsubitem}{(in module audioop)} +\setindexsubitem{(in module audioop)} \begin{excdesc}{error} This exception is raised on all errors, such as unknown number of bytes per sample, etc. @@ -201,7 +201,7 @@ distinction between mono and stereo fragments, i.e.\ all samples are treated equal. If this is a problem the stereo fragment should be split into two mono fragments first and recombined later. Here is an example of how to do that: -\bcode\begin{verbatim} +\begin{verbatim} def mul_stereo(sample, width, lfactor, rfactor): lsample = audioop.tomono(sample, width, 1, 0) rsample = audioop.tomono(sample, width, 0, 1) @@ -210,7 +210,7 @@ def mul_stereo(sample, width, lfactor, rfactor): lsample = audioop.tostereo(lsample, width, 1, 0) rsample = audioop.tostereo(rsample, width, 0, 1) return audioop.add(lsample, rsample, width) -\end{verbatim}\ecode +\end{verbatim} % If you use the ADPCM coder to build network packets and you want your protocol to be stateless (i.e.\ to be able to tolerate packet loss) @@ -231,7 +231,7 @@ They are primarily meant to do echo cancellation. A reasonably fast way to do this is to pick the most energetic piece of the output sample, locate that in the input sample and subtract the whole output sample from the input sample: -\bcode\begin{verbatim} +\begin{verbatim} def echocancel(outputdata, inputdata): pos = audioop.findmax(outputdata, 800) # one tenth second out_test = outputdata[pos*2:] @@ -244,4 +244,4 @@ def echocancel(outputdata, inputdata): postfill = '\0'*(len(inputdata)-len(prefill)-len(outputdata)) outputdata = prefill + audioop.mul(outputdata,2,-factor) + postfill return audioop.add(inputdata, outputdata, 2) -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libbase64.tex b/Doc/lib/libbase64.tex index 831287b..f196451 100644 --- a/Doc/lib/libbase64.tex +++ b/Doc/lib/libbase64.tex @@ -12,7 +12,7 @@ output produced by the \file{uuencode} program. For example, the string \code{'www.python.org'} is encoded as the string \code{'d3d3LnB5dGhvbi5vcmc=\e n'}. -\renewcommand{\indexsubitem}{(in module base64)} +\setindexsubitem{(in module base64)} \begin{funcdesc}{decode}{input, output} Decode the contents of the \var{input} file and write the resulting diff --git a/Doc/lib/libbasehttp.tex b/Doc/lib/libbasehttp.tex index 1f7b6da..c28b0b8 100644 --- a/Doc/lib/libbasehttp.tex +++ b/Doc/lib/libbasehttp.tex @@ -7,7 +7,7 @@ \index{URL} \index{httpd} -\renewcommand{\indexsubitem}{(in module BaseHTTPServer)} +\setindexsubitem{(in module BaseHTTPServer)} This module defines two classes for implementing HTTP servers (web servers). Usually, this module isn't used directly, but is used @@ -21,13 +21,13 @@ subclass. It creates and listens at the web socket, dispatching the requests to a handler. Code to create and run the server looks like this: -\bcode\begin{verbatim} +\begin{verbatim} def run(server_class=BaseHTTPServer.HTTPServer, handler_class=BaseHTTPServer.BaseHTTPRequestHandler): server_address = ('', 8000) httpd = server_class(server_address, handler_class) httpd.serve_forever() -\end{verbatim}\ecode +\end{verbatim} % The \code{HTTPServer} class builds on the \code{TCPServer} class by storing the server address as instance @@ -49,7 +49,7 @@ from the request. For example, for the request \code{SPAM}, the the relevant information is stored into instance variables of the handler. -\renewcommand{\indexsubitem}{(BaseHTTPRequestHandler instance variable)} +\setindexsubitem{(BaseHTTPRequestHandler instance variable)} \code{BaseHTTPRequestHandler} has the following instance variables: @@ -88,7 +88,7 @@ Proper adherance to the HTTP protocol must be used when writing to this stream. \end{datadesc} -\renewcommand{\indexsubitem}{(BaseHTTPRequestHandler class variable)} +\setindexsubitem{(BaseHTTPRequestHandler class variable)} \code{BaseHTTPRequestHandler} has the following class variables: @@ -138,7 +138,7 @@ error response, and \var{longmessage} as the \var{explain} key (see the \code{error_message_format} class variable). \end{datadesc} -\renewcommand{\indexsubitem}{(BaseHTTPRequestHandler method)} +\setindexsubitem{(BaseHTTPRequestHandler method)} A \code{BaseHTTPRequestHandler} instance has the following methods: diff --git a/Doc/lib/libbastion.tex b/Doc/lib/libbastion.tex index dd30284..e9bcc1f 100644 --- a/Doc/lib/libbastion.tex +++ b/Doc/lib/libbastion.tex @@ -1,7 +1,7 @@ \section{Standard Module \sectcode{Bastion}} \label{module-Bastion} \stmodindex{Bastion} -\renewcommand{\indexsubitem}{(in module Bastion)} +\setindexsubitem{(in module Bastion)} % I'm concerned that the word 'bastion' won't be understood by people % for whom English is a second language, making the module name diff --git a/Doc/lib/libbinascii.tex b/Doc/lib/libbinascii.tex index 4ff59ae..02b247c 100644 --- a/Doc/lib/libbinascii.tex +++ b/Doc/lib/libbinascii.tex @@ -9,7 +9,7 @@ decoded), on other platforms only the data fork is handled. The \code{binhex} module defines the following functions: -\renewcommand{\indexsubitem}{(in module binhex)} +\setindexsubitem{(in module binhex)} \begin{funcdesc}{binhex}{input\, output} Convert a binary file with filename \var{input} to binhex file @@ -54,7 +54,7 @@ Jansen. The \code{uu} module defines the following functions: -\renewcommand{\indexsubitem}{(in module uu)} +\setindexsubitem{(in module uu)} \begin{funcdesc}{encode}{in_file\, out_file\optional{\, name\, mode}} Uuencode file \var{in_file} into file \var{out_file}. The uuencoded @@ -82,7 +82,7 @@ bit-manipuation of large amounts of data is slow in python. The \code{binascii} module defines the following functions: -\renewcommand{\indexsubitem}{(in module binascii)} +\setindexsubitem{(in module binascii)} \begin{funcdesc}{a2b_uu}{string} Convert a single line of uuencoded data back to binary and return the diff --git a/Doc/lib/libcd.tex b/Doc/lib/libcd.tex index 6e64b77..b3ca8b2 100644 --- a/Doc/lib/libcd.tex +++ b/Doc/lib/libcd.tex @@ -29,7 +29,7 @@ track. Module \code{cd} defines the following functions and constants: -\renewcommand{\indexsubitem}{(in module cd)} +\setindexsubitem{(in module cd)} \begin{funcdesc}{createparser}{} Create and return an opaque parser object. The methods of the parser @@ -115,7 +115,7 @@ objects (see below). Player objects (returned by \code{cd.open()}) have the following methods: -\renewcommand{\indexsubitem}{(CD player object method)} +\setindexsubitem{(CD player object method)} \begin{funcdesc}{allowremoval}{} Unlocks the eject button on the CD-ROM drive permitting the user to @@ -235,7 +235,7 @@ Pauses the CD if it is playing, and makes it play if it is paused. Parser objects (returned by \code{cd.createparser()}) have the following methods: -\renewcommand{\indexsubitem}{(CD parser object method)} +\setindexsubitem{(CD parser object method)} \begin{funcdesc}{addcallback}{type\, func\, arg} Adds a callback for the parser. The parser has callbacks for eight diff --git a/Doc/lib/libcgi.tex b/Doc/lib/libcgi.tex index 6b50ec8..f115263 100644 --- a/Doc/lib/libcgi.tex +++ b/Doc/lib/libcgi.tex @@ -7,7 +7,7 @@ \indexii{MIME}{headers} \index{URL} -\renewcommand{\indexsubitem}{(in module cgi)} +\setindexsubitem{(in module cgi)} Support module for CGI (Common Gateway Interface) scripts. @@ -40,20 +40,20 @@ by a blank line. The first section contains a number of headers, telling the client what kind of data is following. Python code to generate a minimal header section looks like this: -\bcode\begin{verbatim} +\begin{verbatim} print "Content-type: text/html" # HTML is following print # blank line, end of headers -\end{verbatim}\ecode +\end{verbatim} % The second section is usually HTML, which allows the client software to display nicely formatted text with header, in-line images, etc. Here's Python code that prints a simple piece of HTML: -\bcode\begin{verbatim} +\begin{verbatim} print "<TITLE>CGI script output</TITLE>" print "<H1>This is my first CGI script</H1>" print "Hello, world!" -\end{verbatim}\ecode +\end{verbatim} % (It may not be fully legal HTML according to the letter of the standard, but any browser will understand it.) @@ -77,7 +77,7 @@ dictionary. For instance, the following code (which assumes that the \code{Content-type} header and blank line have already been printed) checks that the fields \code{name} and \code{addr} are both set to a non-empty string: -\bcode\begin{verbatim} +\begin{verbatim} form = cgi.FieldStorage() form_ok = 0 if form.has_key("name") and form.has_key("addr"): @@ -88,7 +88,7 @@ if not form_ok: print "Please fill in the name and addr fields." return ...further form processing here... -\end{verbatim}\ecode +\end{verbatim} % Here the fields, accessed through \code{form[key]}, are themselves instances of \code{FieldStorage} (or \code{MiniFieldStorage}, depending on the form encoding). @@ -101,7 +101,7 @@ name), use the \code{type()} function to determine whether you have a single instance or a list of instances. For example, here's code that concatenates any number of username fields, separated by commas: -\bcode\begin{verbatim} +\begin{verbatim} username = form["username"] if type(username) is type([]): # Multiple username fields specified @@ -116,7 +116,7 @@ if type(username) is type([]): else: # Single username field specified usernames = username.value -\end{verbatim}\ecode +\end{verbatim} % If a field represents an uploaded file, the value attribute reads the entire file in memory as a string. This may not be what you want. You can @@ -124,7 +124,7 @@ test for an uploaded file by testing either the filename attribute or the file attribute. You can then read the data at leasure from the file attribute: -\bcode\begin{verbatim} +\begin{verbatim} fileitem = form["userfile"] if fileitem.file: # It's an uploaded file; count lines @@ -133,7 +133,7 @@ if fileitem.file: line = fileitem.file.readline() if not line: break linecount = linecount + 1 -\end{verbatim}\ecode +\end{verbatim} % The file upload draft standard entertains the possibility of uploading multiple files from one field (using a recursive \code{multipart/*} @@ -267,9 +267,9 @@ Make sure that your script is readable and executable by ``others''; the that the first line of the script contains \code{\#!} starting in column 1 followed by the pathname of the Python interpreter, for instance: -\bcode\begin{verbatim} +\begin{verbatim} #!/usr/local/bin/python -\end{verbatim}\ecode +\end{verbatim} % Make sure the Python interpreter exists and is executable by ``others''. @@ -289,11 +289,11 @@ If you need to load modules from a directory which is not on Python's default module search path, you can change the path in your script, before importing other modules, e.g.: -\bcode\begin{verbatim} +\begin{verbatim} import sys sys.path.insert(0, "/usr/home/joe/lib/python") sys.path.insert(0, "/usr/local/lib/python") -\end{verbatim}\ecode +\end{verbatim} % (This way, the directory inserted last will be searched first!) @@ -327,9 +327,9 @@ Give it the right mode etc, and send it a request. If it's installed in the standard \file{cgi-bin} directory, it should be possible to send it a request by entering a URL into your browser of the form: -\bcode\begin{verbatim} +\begin{verbatim} http://yourhostname/cgi-bin/cgi.py?name=Joe+Blow&addr=At+Home -\end{verbatim}\ecode +\end{verbatim} % If this gives an error of type 404, the server cannot find the script -- perhaps you need to install it in a different directory. If it @@ -345,9 +345,9 @@ The next step could be to call the \code{cgi} module's \code{test()} function from your script: replace its main code with the single statement -\bcode\begin{verbatim} +\begin{verbatim} cgi.test() -\end{verbatim}\ecode +\end{verbatim} % This should produce the same results as those gotten from installing the \file{cgi.py} file itself. @@ -380,7 +380,7 @@ Here are the rules: For example: -\bcode\begin{verbatim} +\begin{verbatim} import sys import traceback print "Content-type: text/html" @@ -391,7 +391,7 @@ try: except: print "\n\n<PRE>" traceback.print_exc() -\end{verbatim}\ecode +\end{verbatim} % Notes: The assignment to \code{sys.stderr} is needed because the traceback prints to \code{sys.stderr}. @@ -402,13 +402,13 @@ If you suspect that there may be a problem in importing the traceback module, you can use an even more robust approach (which only uses built-in modules): -\bcode\begin{verbatim} +\begin{verbatim} import sys sys.stderr = sys.stdout print "Content-type: text/plain" print ...your code here... -\end{verbatim}\ecode +\end{verbatim} % This relies on the Python interpreter to print the traceback. The content type of the output is set to plain text, which disables all diff --git a/Doc/lib/libcmath.tex b/Doc/lib/libcmath.tex index c9886bb..147fa6e 100644 --- a/Doc/lib/libcmath.tex +++ b/Doc/lib/libcmath.tex @@ -2,7 +2,7 @@ \label{module-cmath} \bimodindex{cmath} -\renewcommand{\indexsubitem}{(in module cmath)} +\setindexsubitem{(in module cmath)} This module is always available. It provides access to mathematical functions for complex numbers. The functions are: diff --git a/Doc/lib/libcode.tex b/Doc/lib/libcode.tex index a2d77fe..04790a0 100644 --- a/Doc/lib/libcode.tex +++ b/Doc/lib/libcode.tex @@ -7,7 +7,7 @@ objects. The \code{code} module defines the following functions: -\renewcommand{\indexsubitem}{(in module code)} +\setindexsubitem{(in module code)} \begin{funcdesc}{compile_command}{source, \optional{filename\optional{, symbol}}} This function is useful for programs that want to emulate Python's diff --git a/Doc/lib/libcommands.tex b/Doc/lib/libcommands.tex index e829077..e65e954 100644 --- a/Doc/lib/libcommands.tex +++ b/Doc/lib/libcommands.tex @@ -11,7 +11,7 @@ The \code{commands} module is only usable on systems which support The \code{commands} module defines the following functions: -\renewcommand{\indexsubitem}{(in module commands)} +\setindexsubitem{(in module commands)} \begin{funcdesc}{getstatusoutput}{cmd} Execute the string \var{cmd} in a shell with \code{os.popen()} and return a 2-tuple (status, output). \var{cmd} is actually run as diff --git a/Doc/lib/libcopy.tex b/Doc/lib/libcopy.tex index 60a5b42..1d1fd22 100644 --- a/Doc/lib/libcopy.tex +++ b/Doc/lib/libcopy.tex @@ -1,7 +1,7 @@ \section{Standard Module \sectcode{copy}} \label{module-copy} \stmodindex{copy} -\renewcommand{\indexsubitem}{(copy function)} +\setindexsubitem{(copy function)} \ttindex{copy} \ttindex{deepcopy} @@ -9,12 +9,12 @@ This module provides generic (shallow and deep) copying operations. Interface summary: -\bcode\begin{verbatim} +\begin{verbatim} import copy x = copy.copy(y) # make a shallow copy of y x = copy.deepcopy(y) # make a deep copy of y -\end{verbatim}\ecode +\end{verbatim} % For module specific errors, \code{copy.error} is raised. @@ -76,7 +76,7 @@ to control pickling: they can define methods called \code{__setstate__()}. See the description of module \code{pickle} for information on these methods. \refstmodindex{pickle} -\renewcommand{\indexsubitem}{(copy protocol)} +\setindexsubitem{(copy protocol)} \ttindex{__getinitargs__} \ttindex{__getstate__} \ttindex{__setstate__} diff --git a/Doc/lib/libcopyreg.tex b/Doc/lib/libcopyreg.tex index dffcf43..cffc395 100644 --- a/Doc/lib/libcopyreg.tex +++ b/Doc/lib/libcopyreg.tex @@ -12,7 +12,7 @@ future as well. It provides configuration information about object constructors which are not classes. Such constructors may be factory functions or class instances. -\renewcommand{\indexsubitem}{(in module copy_reg)} +\setindexsubitem{(in module copy_reg)} \begin{funcdesc}{constructor}{object} Declares \var{object} to be a valid constructor. diff --git a/Doc/lib/libcrypt.tex b/Doc/lib/libcrypt.tex index 0ec6e80..64a9bfc 100644 --- a/Doc/lib/libcrypt.tex +++ b/Doc/lib/libcrypt.tex @@ -9,7 +9,7 @@ allowing Python scripts to accept typed passwords from the user, or attempting to crack \UNIX{} passwords with a dictionary. \index{crypt(3)} -\renewcommand{\indexsubitem}{(in module crypt)} +\setindexsubitem{(in module crypt)} \begin{funcdesc}{crypt}{word\, salt} \var{word} will usually be a user's password. \var{salt} is a 2-character string which will be used to select one of 4096 variations diff --git a/Doc/lib/libdbm.tex b/Doc/lib/libdbm.tex index 551a153..416a6b0 100644 --- a/Doc/lib/libdbm.tex +++ b/Doc/lib/libdbm.tex @@ -14,7 +14,7 @@ using the GNU GDBM library. The module defines the following constant and functions: -\renewcommand{\indexsubitem}{(in module dbm)} +\setindexsubitem{(in module dbm)} \begin{excdesc}{error} Raised on dbm-specific errors, such as I/O errors. \code{KeyError} is raised for general mapping errors like specifying an incorrect key. diff --git a/Doc/lib/libdis.tex b/Doc/lib/libdis.tex index 2e4442b..b8998dd 100644 --- a/Doc/lib/libdis.tex +++ b/Doc/lib/libdis.tex @@ -11,10 +11,10 @@ this module takes as an input is defined in the file Example: Given the function myfunc -\bcode\begin{verbatim} +\begin{verbatim} def myfunc(alist): return len(alist) -\end{verbatim}\ecode +\end{verbatim} the following command can be used to get the disassembly of \code{myfunc()}: @@ -33,7 +33,7 @@ the following command can be used to get the disassembly of \code{myfunc()}: The \code{dis} module defines the following functions: -\renewcommand{\indexsubitem}{(in module dis)} +\setindexsubitem{(in module dis)} \begin{funcdesc}{dis}{\optional{bytesource}} Disassemble the \var{bytesource} object. \var{bytesource} can denote @@ -107,7 +107,7 @@ Sequence of byte codes of boolean operations. The Python compiler currently generates the following byte code instructions. -\renewcommand{\indexsubitem}{(byte code insns)} +\setindexsubitem{(byte code insns)} \begin{opcodedesc}{STOP_CODE}{} Indicates end-of-code to the compiler, not used by the interpreter. @@ -507,5 +507,5 @@ default parameters, which are found below TOS. Pushes a slice object on the stack. \var{argc} must be 2 or 3. If it is 2, \code{slice(TOS1, TOS)} is pushed; if it is 3, \code{slice(TOS2, TOS1, TOS)} is pushed. -See the \code{slice()} built-in function. +See the \code{slice()}\bifuncindex{slice} built-in function. \end{opcodedesc} diff --git a/Doc/lib/liberrno.tex b/Doc/lib/liberrno.tex index 2c45266..cf5f854 100644 --- a/Doc/lib/liberrno.tex +++ b/Doc/lib/liberrno.tex @@ -1,7 +1,7 @@ \section{Standard Module \sectcode{errno}} \stmodindex{errno} -\renewcommand{\indexsubitem}{(in module errno)} +\setindexsubitem{(in module errno)} This module makes available standard errno system symbols. The value of each symbol is the corresponding integer value. diff --git a/Doc/lib/libexcs.tex b/Doc/lib/libexcs.tex index 758c14a..bb27b16 100644 --- a/Doc/lib/libexcs.tex +++ b/Doc/lib/libexcs.tex @@ -52,7 +52,7 @@ situation in which the interpreter raises the same exception; but beware that there is nothing to prevent user code from raising an inappropriate error. -\renewcommand{\indexsubitem}{(built-in exception base class)} +\setindexsubitem{(built-in exception base class)} The following exceptions are only used as base classes for other exceptions. When string-based standard exceptions are used, they @@ -87,7 +87,7 @@ index used on a mapping or sequence is invalid: \code{IndexError}, \code{KeyError}. \end{excdesc} -\renewcommand{\indexsubitem}{(built-in exception)} +\setindexsubitem{(built-in exception)} The following exceptions are the exceptions that are actually raised. They are class objects, except when the \code{-X} option is used to diff --git a/Doc/lib/libfcntl.tex b/Doc/lib/libfcntl.tex index 5dab283..8af4ee3 100644 --- a/Doc/lib/libfcntl.tex +++ b/Doc/lib/libfcntl.tex @@ -11,7 +11,7 @@ file or socket object. The module defines the following functions: -\renewcommand{\indexsubitem}{(in module struct)} +\setindexsubitem{(in module struct)} \begin{funcdesc}{fcntl}{fd\, op\optional{\, arg}} Perform the requested operation on file descriptor \code{\var{fd}}. @@ -56,7 +56,7 @@ script, found in the \file{Tools/scripts} directory. Examples (all on a SVR4 compliant system): -\bcode\begin{verbatim} +\begin{verbatim} import struct, FCNTL file = open(...) @@ -64,7 +64,7 @@ rv = fcntl(file.fileno(), FCNTL.O_NDELAY, 1) lockdata = struct.pack('hhllhh', FCNTL.F_WRLCK, 0, 0, 0, 0, 0) rv = fcntl(file.fileno(), FCNTL.F_SETLKW, lockdata) -\end{verbatim}\ecode +\end{verbatim} % Note that in the first example the return value variable \code{rv} will hold an integer value; in the second example it will hold a string diff --git a/Doc/lib/libfl.tex b/Doc/lib/libfl.tex index 1c58a7e..4fa62a8 100644 --- a/Doc/lib/libfl.tex +++ b/Doc/lib/libfl.tex @@ -41,7 +41,7 @@ Module \code{fl} defines the following functions. For more information about what they do, see the description of the equivalent C function in the FORMS documentation: -\renewcommand{\indexsubitem}{(in module fl)} +\setindexsubitem{(in module fl)} \begin{funcdesc}{make_form}{type\, width\, height} Create a form with given type, width and height. This returns a \dfn{form} object, whose methods are described below. @@ -146,7 +146,7 @@ kinds of FORMS object also have some methods specific to that kind; these methods are listed here. \begin{flushleft} -\renewcommand{\indexsubitem}{(form object method)} +\setindexsubitem{(form object method)} \begin{funcdesc}{show_form}{placement\, bordertype\, name} Show the form. \end{funcdesc} @@ -389,7 +389,7 @@ documentation: Besides methods specific to particular kinds of FORMS objects, all FORMS objects also have the following methods: -\renewcommand{\indexsubitem}{(FORMS object method)} +\setindexsubitem{(FORMS object method)} \begin{funcdesc}{set_call_back}{function\, argument} Set the object's callback function and argument. When the object needs interaction, the callback function will be called with two @@ -468,10 +468,10 @@ the C header file \file{<forms.h>} except that the name prefix \samp{FL_} is omitted. Read the module source for a complete list of the defined names. Suggested use: -\bcode\begin{verbatim} +\begin{verbatim} import fl from FL import * -\end{verbatim}\ecode +\end{verbatim} % \section{Standard Module \sectcode{flp}} \label{module-flp} diff --git a/Doc/lib/libfm.tex b/Doc/lib/libfm.tex index fa469fc..9d22123 100644 --- a/Doc/lib/libfm.tex +++ b/Doc/lib/libfm.tex @@ -14,7 +14,7 @@ details of font info; individual glyph metrics; and printer matching. It supports the following operations: -\renewcommand{\indexsubitem}{(in module fm)} +\setindexsubitem{(in module fm)} \begin{funcdesc}{init}{} Initialization function. Calls \code{fminit()}. @@ -50,7 +50,7 @@ Returns the current font search path. Font handle objects support the following operations: -\renewcommand{\indexsubitem}{(font handle method)} +\setindexsubitem{(font handle method)} \begin{funcdesc}{scalefont}{factor} Returns a handle for a scaled version of this font. Calls \code{fmscalefont(\var{fh}, \var{factor})}. diff --git a/Doc/lib/libfnmatch.tex b/Doc/lib/libfnmatch.tex index ecb77d3..7aa1295 100644 --- a/Doc/lib/libfnmatch.tex +++ b/Doc/lib/libfnmatch.tex @@ -18,7 +18,7 @@ special to this module. See module \code{glob}\refstmodindex{glob} for pathname expansion (\code{glob} uses \code{fnmatch()} to match filename segments). -\renewcommand{\indexsubitem}{(in module fnmatch)} +\setindexsubitem{(in module fnmatch)} \begin{funcdesc}{fnmatch}{filename, pattern} Test whether the \var{filename} string matches the \var{pattern} diff --git a/Doc/lib/libformatter.tex b/Doc/lib/libformatter.tex index 124ca52..1a5150d 100644 --- a/Doc/lib/libformatter.tex +++ b/Doc/lib/libformatter.tex @@ -2,7 +2,7 @@ \label{module-formatter} \stmodindex{formatter} -\renewcommand{\indexsubitem}{(in module formatter)} +\setindexsubitem{(in module formatter)} This module supports two interface definitions, each with mulitple implementations. The \emph{formatter} interface is used by the @@ -47,14 +47,14 @@ be called without having to track whether the property was changed. The following attributes are defined for formatter instance objects: -\renewcommand{\indexsubitem}{(formatter object data)} +\setindexsubitem{(formatter object data)} \begin{datadesc}{writer} The writer instance with which the formatter interacts. \end{datadesc} -\renewcommand{\indexsubitem}{(formatter object method)} +\setindexsubitem{(formatter object method)} \begin{funcdesc}{end_paragraph}{blanklines} Close any open paragraphs and insert at least \code{blanklines} @@ -187,7 +187,7 @@ Two implementations of formatter objects are provided by this module. Most applications may use one of these classes without modification or subclassing. -\renewcommand{\indexsubitem}{(in module formatter)} +\setindexsubitem{(in module formatter)} \begin{funcdesc}{NullFormatter}{\optional{writer\code{ = None}}} A formatter which does nothing. If \code{writer} is omitted, a @@ -215,7 +215,7 @@ Note that while most applications can use the \code{AbstractFormatter} class as a formatter, the writer must typically be provided by the application. -\renewcommand{\indexsubitem}{(writer object method)} +\setindexsubitem{(writer object method)} \begin{funcdesc}{flush}{} Flush any buffered output or device control events. @@ -307,7 +307,7 @@ Three implementations of the writer object interface are provided as examples by this module. Most applications will need to derive new writer classes from the \code{NullWriter} class. -\renewcommand{\indexsubitem}{(in module formatter)} +\setindexsubitem{(in module formatter)} \begin{funcdesc}{NullWriter}{} A writer which only provides the interface definition; no actions are diff --git a/Doc/lib/libftplib.tex b/Doc/lib/libftplib.tex index 86c3b3e..39f5657 100644 --- a/Doc/lib/libftplib.tex +++ b/Doc/lib/libftplib.tex @@ -3,7 +3,7 @@ \stmodindex{ftplib} \indexii{FTP}{protocol} -\renewcommand{\indexsubitem}{(in module ftplib)} +\setindexsubitem{(in module ftplib)} This module defines the class \code{FTP} and a few related items. The \code{FTP} class implements the client side of the FTP protocol. You @@ -14,7 +14,7 @@ more information on FTP (File Transfer Protocol), see Internet \rfc{959}. Here's a sample session using the \code{ftplib} module: -\bcode\begin{verbatim} +\begin{verbatim} >>> from ftplib import FTP >>> ftp = FTP('ftp.cwi.nl') # connect to host, default port >>> ftp.login() # user anonymous, passwd user@hostname @@ -27,7 +27,7 @@ dr-xr-srwt 105 ftp-usr pdmaint 1536 Mar 21 14:32 .. . . >>> ftp.quit() -\end{verbatim}\ecode +\end{verbatim} % The module defines the following items: @@ -68,7 +68,7 @@ not begin with a digit in the range 1--5. FTP instances have the following methods: -\renewcommand{\indexsubitem}{(FTP object method)} +\setindexsubitem{(FTP object method)} \begin{funcdesc}{set_debuglevel}{level} Set the instance's debugging level. This controls the amount of diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex index 6d1cbce..6a2b0a5 100644 --- a/Doc/lib/libfuncs.tex +++ b/Doc/lib/libfuncs.tex @@ -5,7 +5,7 @@ The Python interpreter has a number of functions built into it that are always available. They are listed here in alphabetical order. -\renewcommand{\indexsubitem}{(built-in function)} +\setindexsubitem{(built-in function)} \begin{funcdesc}{__import__}{name\optional{, globals\optional{, locals\optional{, fromlist}}}} This function is invoked by the \code{import} statement. It @@ -135,14 +135,14 @@ class instances are callable if they have an attribute \code{__call__}. and for class instances, methods are not included. The resulting list is sorted alphabetically. For example: -\bcode\begin{verbatim} +\begin{verbatim} >>> import sys >>> dir() ['sys'] >>> dir(sys) ['argv', 'exit', 'modules', 'path', 'stderr', 'stdin', 'stdout'] >>> -\end{verbatim}\ecode +\end{verbatim} \end{funcdesc} \begin{funcdesc}{divmod}{a\, b} @@ -166,12 +166,12 @@ class instances are callable if they have an attribute \code{__call__}. called. The return value is the result of the evaluated expression. Syntax errors are reported as exceptions. Example: -\bcode\begin{verbatim} +\begin{verbatim} >>> x = 1 >>> print eval('x+1') 2 >>> -\end{verbatim}\ecode +\end{verbatim} % This function can also be used to execute arbitrary code objects (e.g.\ created by \code{compile()}). In this case pass a code @@ -448,7 +448,7 @@ there's no reliable way to determine whether this is the case.} greater than \var{stop}. \var{step} must not be zero (or else an exception is raised). Example: -\bcode\begin{verbatim} +\begin{verbatim} >>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> range(1, 11) @@ -464,7 +464,7 @@ there's no reliable way to determine whether this is the case.} >>> range(1, 0) [] >>> -\end{verbatim}\ecode +\end{verbatim} \end{funcdesc} \begin{funcdesc}{raw_input}{\optional{prompt}} @@ -473,13 +473,13 @@ there's no reliable way to determine whether this is the case.} converts it to a string (stripping a trailing newline), and returns that. When \EOF{} is read, \code{EOFError} is raised. Example: -\bcode\begin{verbatim} +\begin{verbatim} >>> s = raw_input('--> ') --> Monty Python's Flying Circus >>> s "Monty Python's Flying Circus" >>> -\end{verbatim}\ecode +\end{verbatim} If the \code{readline} module was loaded, then \code{raw_input()} will use it to provide elaborate @@ -604,10 +604,10 @@ built-in types. \obindex{type} For instance: -\bcode\begin{verbatim} +\begin{verbatim} >>> import types >>> if isinstance(x, types.StringType): print "It's a string" -\end{verbatim}\ecode +\end{verbatim} \end{funcdesc} \begin{funcdesc}{vars}{\optional{object}} diff --git a/Doc/lib/libgdbm.tex b/Doc/lib/libgdbm.tex index ea655a3..d42bf85 100644 --- a/Doc/lib/libgdbm.tex +++ b/Doc/lib/libgdbm.tex @@ -15,7 +15,7 @@ Printing a \code{gdbm} object doesn't print the keys and values, and the The module defines the following constant and functions: -\renewcommand{\indexsubitem}{(in module gdbm)} +\setindexsubitem{(in module gdbm)} \begin{excdesc}{error} Raised on \code{gdbm}-specific errors, such as I/O errors. \code{KeyError} is raised for general mapping errors like specifying an incorrect key. @@ -57,12 +57,12 @@ method returns the starting key. Returns the key that follows \var{key} in the traversal. The following code prints every key in the database \code{db}, without having to create a list in memory that contains them all: -\bcode\begin{verbatim} +\begin{verbatim} k=db.firstkey() while k!=None: print k k=db.nextkey(k) -\end{verbatim}\ecode +\end{verbatim} \end{funcdesc} \begin{funcdesc}{reorganize}{} diff --git a/Doc/lib/libgetopt.tex b/Doc/lib/libgetopt.tex index a9210b0..286cf58 100644 --- a/Doc/lib/libgetopt.tex +++ b/Doc/lib/libgetopt.tex @@ -45,7 +45,7 @@ be mixed. An example using only \UNIX{} style options: -\bcode\begin{verbatim} +\begin{verbatim} >>> import getopt, string >>> args = string.split('-a -b -cfoo -d bar a1 a2') >>> args @@ -56,11 +56,11 @@ An example using only \UNIX{} style options: >>> args ['a1', 'a2'] >>> -\end{verbatim}\ecode +\end{verbatim} % Using long option names is equally easy: -\bcode\begin{verbatim} +\begin{verbatim} >>> s = '--condition=foo --testing --output-file abc.def -x a1 a2' >>> args = string.split(s) >>> args @@ -72,7 +72,7 @@ Using long option names is equally easy: >>> args ['a1', 'a2'] >>> -\end{verbatim}\ecode +\end{verbatim} % The exception \code{getopt.error} diff --git a/Doc/lib/libgl.tex b/Doc/lib/libgl.tex index b168681..b694d86 100644 --- a/Doc/lib/libgl.tex +++ b/Doc/lib/libgl.tex @@ -41,15 +41,15 @@ All (short, long, unsigned) integer arguments or return values that are only used to specify the length of an array argument are omitted. For example, the C call -\bcode\begin{verbatim} +\begin{verbatim} lmdef(deftype, index, np, props) -\end{verbatim}\ecode +\end{verbatim} % is translated to Python as -\bcode\begin{verbatim} +\begin{verbatim} lmdef(deftype, index, props) -\end{verbatim}\ecode +\end{verbatim} % \item Output arguments are omitted from the argument list; they are @@ -60,22 +60,22 @@ because of the previous rule) and an output argument, the return value comes first in the tuple. Examples: the C call -\bcode\begin{verbatim} +\begin{verbatim} getmcolor(i, &red, &green, &blue) -\end{verbatim}\ecode +\end{verbatim} % is translated to Python as -\bcode\begin{verbatim} +\begin{verbatim} red, green, blue = getmcolor(i) -\end{verbatim}\ecode +\end{verbatim} % \end{itemize} The following functions are non-standard or have special argument conventions: -\renewcommand{\indexsubitem}{(in module gl)} +\setindexsubitem{(in module gl)} \begin{funcdesc}{varray}{argument} %JHXXX the argument-argument added Equivalent to but faster than a number of @@ -160,7 +160,7 @@ No method is provided to detect buffer overrun. Here is a tiny but complete example GL program in Python: -\bcode\begin{verbatim} +\begin{verbatim} import gl, GL, time def main(): @@ -182,7 +182,7 @@ def main(): time.sleep(5) main() -\end{verbatim}\ecode +\end{verbatim} % \section{Standard Modules \sectcode{GL} and \sectcode{DEVICE}} \nodename{GL and DEVICE} diff --git a/Doc/lib/libglob.tex b/Doc/lib/libglob.tex index 3f21b39..58193c9 100644 --- a/Doc/lib/libglob.tex +++ b/Doc/lib/libglob.tex @@ -1,7 +1,7 @@ \section{Standard Module \sectcode{glob}} \label{module-glob} \stmodindex{glob} -\renewcommand{\indexsubitem}{(in module glob)} +\setindexsubitem{(in module glob)} The \code{glob} module finds all the pathnames matching a specified pattern according to the rules used by the \UNIX{} shell. No tilde @@ -25,7 +25,7 @@ For example, consider a directory containing only the following files: will produce the following results. Notice how any leading components of the path are preserved. -\bcode\begin{verbatim} +\begin{verbatim} >>> import glob >>> glob.glob('./[0-9].*') ['./1.gif', './2.txt'] @@ -33,4 +33,4 @@ of the path are preserved. ['1.gif', 'card.gif'] >>> glob.glob('?.gif') ['1.gif'] -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libgopherlib.tex b/Doc/lib/libgopherlib.tex index b0ebcf7..eb6d2a6 100644 --- a/Doc/lib/libgopherlib.tex +++ b/Doc/lib/libgopherlib.tex @@ -3,7 +3,7 @@ \stmodindex{gopherlib} \indexii{Gopher}{protocol} -\renewcommand{\indexsubitem}{(in module gopherlib)} +\setindexsubitem{(in module gopherlib)} This module provides a minimal implementation of client side of the the Gopher protocol. It is used by the module \code{urllib} to handle diff --git a/Doc/lib/libgrp.tex b/Doc/lib/libgrp.tex index ab90485..478097d 100644 --- a/Doc/lib/libgrp.tex +++ b/Doc/lib/libgrp.tex @@ -19,7 +19,7 @@ A \code{KeyError} exception is raised if the entry asked for cannot be found. It defines the following items: -\renewcommand{\indexsubitem}{(in module grp)} +\setindexsubitem{(in module grp)} \begin{funcdesc}{getgrgid}{gid} Return the group database entry for the given numeric group ID. \end{funcdesc} diff --git a/Doc/lib/libgzip.tex b/Doc/lib/libgzip.tex index f832da7..df99e5d 100644 --- a/Doc/lib/libgzip.tex +++ b/Doc/lib/libgzip.tex @@ -12,7 +12,7 @@ or decompressing the data so it looks like an ordinary file object. object, though it's not possible to use the \code{seek()} and \code{tell()} methods to access the file randomly. -\renewcommand{\indexsubitem}{(in module gzip)} +\setindexsubitem{(in module gzip)} \begin{funcdesc}{open}{fileobj\optional{\, filename\optional{\, mode\, compresslevel}}} Returns a new \code{GzipFile} object on top of \var{fileobj}, which can be a regular file, a \code{StringIO} object, or any object which diff --git a/Doc/lib/libhtmllib.tex b/Doc/lib/libhtmllib.tex index b9b29d4..b05c470 100644 --- a/Doc/lib/libhtmllib.tex +++ b/Doc/lib/libhtmllib.tex @@ -4,7 +4,7 @@ \index{HTML} \index{hypertext} -\renewcommand{\indexsubitem}{(in module htmllib)} +\setindexsubitem{(in module htmllib)} This module defines a class which can serve as a base for parsing text files formatted in the HyperText Mark-up Language (HTML). The class @@ -40,10 +40,10 @@ incomplete elements are saved in a buffer. To force processing of all unprocessed data, call the \method{close()} method. For example, to parse the entire contents of a file, use: -\bcode\begin{verbatim} +\begin{verbatim} parser.feed(open('myfile.html').read()) parser.close() -\end{verbatim}\ecode +\end{verbatim} % \item The interface to define semantics for HTML tags is very simple: derive @@ -71,7 +71,7 @@ handlers for all HTML 2.0 and many HTML 3.0 and 3.2 elements. In addition to tag methods, the \class{HTMLParser} class provides some additional methods and instance variables for use within tag methods. -\renewcommand{\indexsubitem}{(HTMLParser attribute)} +\setindexsubitem{(HTMLParser attribute)} \begin{datadesc}{formatter} This is the formatter instance associated with the parser. @@ -85,7 +85,7 @@ as within a \code{<PRE>} element. The default value is false. This affects the operation of \method{handle_data()} and \method{save_end()}. \end{datadesc} -\renewcommand{\indexsubitem}{(HTMLParser method)} +\setindexsubitem{(HTMLParser method)} \begin{funcdesc}{anchor_bgn}{href\, name\, type} This method is called at the start of an anchor region. The arguments diff --git a/Doc/lib/libhttplib.tex b/Doc/lib/libhttplib.tex index 0bca8ad..ed59c9c 100644 --- a/Doc/lib/libhttplib.tex +++ b/Doc/lib/libhttplib.tex @@ -3,7 +3,7 @@ \stmodindex{httplib} \index{HTTP} -\renewcommand{\indexsubitem}{(in module httplib)} +\setindexsubitem{(in module httplib)} This module defines a class which implements the client side of the HTTP protocol. It is normally not used directly --- the module @@ -20,11 +20,11 @@ method should be used to connect to a server. For example, the following calls all create instances that connect to the server at the same host and port: -\bcode\begin{verbatim} +\begin{verbatim} >>> h1 = httplib.HTTP('www.cwi.nl') >>> h2 = httplib.HTTP('www.cwi.nl:80') >>> h3 = httplib.HTTP('www.cwi.nl', 80) -\end{verbatim}\ecode +\end{verbatim} % Once an \code{HTTP} instance has been connected to an HTTP server, it should be used as follows: @@ -51,7 +51,7 @@ file object that it returns. \code{HTTP} instances have the following methods: -\renewcommand{\indexsubitem}{(HTTP method)} +\setindexsubitem{(HTTP method)} \begin{funcdesc}{set_debuglevel}{level} Set the debugging level (the amount of debugging output printed). @@ -112,7 +112,7 @@ methods. Here is an example session: -\bcode\begin{verbatim} +\begin{verbatim} >>> import httplib >>> h = httplib.HTTP('www.cwi.nl') >>> h.putrequest('GET', '/index.html') @@ -125,4 +125,4 @@ Here is an example session: >>> data = f.read() # Get the raw HTML >>> f.close() >>> -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libimageop.tex b/Doc/lib/libimageop.tex index 48f9188..e5d494d 100644 --- a/Doc/lib/libimageop.tex +++ b/Doc/lib/libimageop.tex @@ -9,7 +9,7 @@ by \code{gl.lrectwrite} and the \code{imgfile} module. The module defines the following variables and functions: -\renewcommand{\indexsubitem}{(in module imageop)} +\setindexsubitem{(in module imageop)} \begin{excdesc}{error} This exception is raised on all errors, such as unknown number of bits diff --git a/Doc/lib/libimgfile.tex b/Doc/lib/libimgfile.tex index 96afc9b..098d59b 100644 --- a/Doc/lib/libimgfile.tex +++ b/Doc/lib/libimgfile.tex @@ -9,7 +9,7 @@ is enough in some cases. Currently, colormap files are not supported. The module defines the following variables and functions: -\renewcommand{\indexsubitem}{(in module imgfile)} +\setindexsubitem{(in module imgfile)} \begin{excdesc}{error} This exception is raised on all errors, such as unsupported file type, etc. \end{excdesc} diff --git a/Doc/lib/libimghdr.tex b/Doc/lib/libimghdr.tex index e8ec4e9..71ef949 100644 --- a/Doc/lib/libimghdr.tex +++ b/Doc/lib/libimghdr.tex @@ -7,7 +7,7 @@ file or byte stream. The \code{imghdr} module defines the following function: -\renewcommand{\indexsubitem}{(in module imghdr)} +\setindexsubitem{(in module imghdr)} \begin{funcdesc}{what}{filename\optional{\, h}} Tests the image data contained in the file named by \var{filename}, @@ -54,8 +54,8 @@ the test succeeded, or \code{None} if it failed. Example: -\bcode\begin{verbatim} +\begin{verbatim} >>> import imghdr >>> imghdr.what('/tmp/bass.gif') 'gif' -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libimp.tex b/Doc/lib/libimp.tex index 0ba0770..5ad2fff 100644 --- a/Doc/lib/libimp.tex +++ b/Doc/lib/libimp.tex @@ -7,7 +7,7 @@ This module provides an interface to the mechanisms used to implement the \code{import} statement. It defines the following constants and functions: -\renewcommand{\indexsubitem}{(in module imp)} +\setindexsubitem{(in module imp)} \begin{funcdesc}{get_magic}{} Return the magic string value used to recognize byte-compiled code @@ -206,7 +206,7 @@ up to Python 1.4 (i.e., no hierarchical module names). (This \code{imp.find_module()} has been extended and \code{imp.load_module()} has been added in 1.4.) -\bcode\begin{verbatim} +\begin{verbatim} import imp import sys def __import__(name, globals=None, locals=None, fromlist=None): @@ -227,7 +227,7 @@ def __import__(name, globals=None, locals=None, fromlist=None): # Since we may exit via an exception, close fp explicitly. if fp: fp.close() -\end{verbatim}\ecode +\end{verbatim} A more complete example that implements hierarchical module names and includes a \code{reload()} function can be found in the standard diff --git a/Doc/lib/libjpeg.tex b/Doc/lib/libjpeg.tex index 0d1dc1c..75691cf 100644 --- a/Doc/lib/libjpeg.tex +++ b/Doc/lib/libjpeg.tex @@ -10,7 +10,7 @@ documentation provided with the software. The \code{jpeg} module defines these functions: -\renewcommand{\indexsubitem}{(in module jpeg)} +\setindexsubitem{(in module jpeg)} \begin{funcdesc}{compress}{data\, w\, h\, b} Treat data as a pixmap of width \var{w} and height \var{h}, with \var{b} bytes per pixel. The data is in SGI GL order, so the first pixel is in the diff --git a/Doc/lib/liblocale.tex b/Doc/lib/liblocale.tex index a0ecf39..84eaf75 100644 --- a/Doc/lib/liblocale.tex +++ b/Doc/lib/liblocale.tex @@ -16,7 +16,7 @@ available. The \code{locale} module defines the following functions: -\renewcommand{\indexsubitem}{(in module locale)} +\setindexsubitem{(in module locale)} \begin{funcdesc}{setlocale}{category\optional{\, value}} If \var{value} is specified, modifies the locale setting for the @@ -31,10 +31,10 @@ If no \var{value} is specified, the current setting for the \code{setlocale()} is not thread safe on most systems. Applications typically start with a call of -\bcode\begin{verbatim} +\begin{verbatim} import locale locale.setlocale(locale.LC_ALL,"") -\end{verbatim}\ecode +\end{verbatim} This sets the locale for all categories to the user's default setting (typically specified in the \code{LANG} environment variable). If the locale is not changed thereafter, using multithreading should not @@ -182,9 +182,9 @@ Exception raised when \code{setlocale()} fails. Example: -\bcode\begin{verbatim} +\begin{verbatim} >>> import locale >>> locale.open(locale.LC_ALL,"de") #setting locale to German >>> locale.strcoll("f\344n","foo") #comparing a string containing an umlaut >>> can.close() -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libmailbox.tex b/Doc/lib/libmailbox.tex index 42bdfda..d616f36 100644 --- a/Doc/lib/libmailbox.tex +++ b/Doc/lib/libmailbox.tex @@ -2,7 +2,7 @@ \label{module-mailbox} \stmodindex{mailbox} -\renewcommand{\indexsubitem}{(in module mailbox)} +\setindexsubitem{(in module mailbox)} This module defines a number of classes that allow easy and uniform access to mail messages in a (unix) mailbox. diff --git a/Doc/lib/libmailcap.tex b/Doc/lib/libmailcap.tex index b475b11..ecc8369 100644 --- a/Doc/lib/libmailcap.tex +++ b/Doc/lib/libmailcap.tex @@ -1,7 +1,7 @@ \section{Standard Module \sectcode{mailcap}} \label{module-mailcap} \stmodindex{mailcap} -\renewcommand{\indexsubitem}{(in module mailcap)} +\setindexsubitem{(in module mailcap)} Mailcap files are used to configure how MIME-aware applications such as mail readers and Web browsers react to files with different MIME @@ -69,9 +69,9 @@ will override settings in the system mailcap files \end{funcdesc} An example usage: -\bcode\begin{verbatim} +\begin{verbatim} >>> import mailcap >>> d=mailcap.getcaps() >>> mailcap.findmatch(d, 'video/mpeg', filename='/tmp/tmp1223') ('xmpeg /tmp/tmp1223', {'view': 'xmpeg %s'}) -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libmarshal.tex b/Doc/lib/libmarshal.tex index dc4ed98..fddbba4 100644 --- a/Doc/lib/libmarshal.tex +++ b/Doc/lib/libmarshal.tex @@ -54,7 +54,7 @@ operating on strings. The module defines these functions: -\renewcommand{\indexsubitem}{(in module marshal)} +\setindexsubitem{(in module marshal)} \begin{funcdesc}{dump}{value\, file} Write the value on the open file. The value must be a supported diff --git a/Doc/lib/libmath.tex b/Doc/lib/libmath.tex index c40030b..7f5679c 100644 --- a/Doc/lib/libmath.tex +++ b/Doc/lib/libmath.tex @@ -2,7 +2,7 @@ \label{module-math} \bimodindex{math} -\renewcommand{\indexsubitem}{(in module math)} +\setindexsubitem{(in module math)} This module is always available. It provides access to the mathematical functions defined by the \C{} standard. diff --git a/Doc/lib/libmd5.tex b/Doc/lib/libmd5.tex index bbf7172..946d00d 100644 --- a/Doc/lib/libmd5.tex +++ b/Doc/lib/libmd5.tex @@ -14,23 +14,23 @@ so far using the \code{digest()} method. For example, to obtain the digest of the string {\tt"Nobody inspects the spammish repetition"}: -\bcode\begin{verbatim} +\begin{verbatim} >>> import md5 >>> m = md5.new() >>> m.update("Nobody inspects") >>> m.update(" the spammish repetition") >>> m.digest() '\273d\234\203\335\036\245\311\331\336\311\241\215\360\377\351' -\end{verbatim}\ecode +\end{verbatim} % More condensed: -\bcode\begin{verbatim} +\begin{verbatim} >>> md5.new("Nobody inspects the spammish repetition").digest() '\273d\234\203\335\036\245\311\331\336\311\241\215\360\377\351' -\end{verbatim}\ecode +\end{verbatim} % -\renewcommand{\indexsubitem}{(in module md5)} +\setindexsubitem{(in module md5)} \begin{funcdesc}{new}{\optional{arg}} Return a new md5 object. If \var{arg} is present, the method call @@ -44,7 +44,7 @@ For backward compatibility reasons, this is an alternative name for the An md5 object has the following methods: -\renewcommand{\indexsubitem}{(md5 method)} +\setindexsubitem{(md5 method)} \begin{funcdesc}{update}{arg} Update the md5 object with the string \var{arg}. Repeated calls are equivalent to a single call with the concatenation of all the diff --git a/Doc/lib/libmimetools.tex b/Doc/lib/libmimetools.tex index 41a62ba..94601b3 100644 --- a/Doc/lib/libmimetools.tex +++ b/Doc/lib/libmimetools.tex @@ -2,7 +2,7 @@ \label{module-mimetools} \stmodindex{mimetools} -\renewcommand{\indexsubitem}{(in module mimetools)} +\setindexsubitem{(in module mimetools)} This module defines a subclass of the class \code{rfc822.Message} and a number of utility functions that are useful for the manipulation for @@ -52,7 +52,7 @@ file \var{output}. The block size is currently fixed at 8192. The \code{mimetools.Message} class defines the following methods in addition to the \code{rfc822.Message} class: -\renewcommand{\indexsubitem}{(mimetool.Message method)} +\setindexsubitem{(mimetool.Message method)} \begin{funcdesc}{getplist}{} Return the parameter list of the \code{Content-type} header. This is diff --git a/Doc/lib/libmimify.tex b/Doc/lib/libmimify.tex index 171e7d2..2982755 100644 --- a/Doc/lib/libmimify.tex +++ b/Doc/lib/libmimify.tex @@ -1,6 +1,6 @@ \section{Standard Module \sectcode{mimify}} \stmodindex{mimify} -\renewcommand{\indexsubitem}{(in module mimify)} +\setindexsubitem{(in module mimify)} The mimify module defines two functions to convert mail messages to and from MIME format. The mail message can be either a simple message diff --git a/Doc/lib/libmpz.tex b/Doc/lib/libmpz.tex index 7ab5fe7..07b2170 100644 --- a/Doc/lib/libmpz.tex +++ b/Doc/lib/libmpz.tex @@ -24,7 +24,7 @@ You create an mpz-number by calling the function called \code{mpz} (see below for an exact description). An mpz-number is printed like this: \code{mpz(\var{value})}. -\renewcommand{\indexsubitem}{(in module mpz)} +\setindexsubitem{(in module mpz)} \begin{funcdesc}{mpz}{value} Create a new mpz-number. \var{value} can be an integer, a long, another mpz-number, or even a string. If it is a string, it is @@ -69,7 +69,7 @@ return mpz-numbers. An mpz-number has one method: -\renewcommand{\indexsubitem}{(mpz method)} +\setindexsubitem{(mpz method)} \begin{funcdesc}{binary}{} Convert this mpz-number to a binary string, where the number has been stored as an array of radix-256 digits, least significant digit first. diff --git a/Doc/lib/libni.tex b/Doc/lib/libni.tex index 219f081..8a251da 100644 --- a/Doc/lib/libni.tex +++ b/Doc/lib/libni.tex @@ -28,20 +28,20 @@ To import module \code{ham} from package \code{spam} and use function \code{hamneggs()} from that module, you can use any of the following possibilities: -\bcode\begin{verbatim} +\begin{verbatim} import spam.ham # *not* "import spam" !!! spam.ham.hamneggs() -\end{verbatim}\ecode +\end{verbatim} % -\bcode\begin{verbatim} +\begin{verbatim} from spam import ham ham.hamneggs() -\end{verbatim}\ecode +\end{verbatim} % -\bcode\begin{verbatim} +\begin{verbatim} from spam.ham import hamneggs hamneggs() -\end{verbatim}\ecode +\end{verbatim} % \code{import spam} creates an empty package named \code{spam} if one does not already exist, but it does @@ -52,9 +52,9 @@ The only submodule that is guaranteed to be imported is \code{spam.__init__} is a submodule of package spam. It can refer to spam's namespace as \code{__} (two underscores): -\bcode\begin{verbatim} +\begin{verbatim} __.spam_inited = 1 # Set a package-level variable -\end{verbatim}\ecode +\end{verbatim} % Additional initialization code (setting up variables, importing other submodules) can be performed in \file{spam/__init__.py}. diff --git a/Doc/lib/libnntplib.tex b/Doc/lib/libnntplib.tex index c0a3138..7ca8a7a 100644 --- a/Doc/lib/libnntplib.tex +++ b/Doc/lib/libnntplib.tex @@ -3,7 +3,7 @@ \stmodindex{nntplib} \indexii{NNTP}{protocol} -\renewcommand{\indexsubitem}{(in module nntplib)} +\setindexsubitem{(in module nntplib)} This module defines the class \code{NNTP} which implements the client side of the NNTP protocol. It can be used to implement a news reader @@ -14,7 +14,7 @@ Here are two small examples of how it can be used. To list some statistics about a newsgroup and print the subjects of the last 10 articles: -\bcode\begin{verbatim} +\begin{verbatim} >>> s = NNTP('news.cwi.nl') >>> resp, count, first, last, name = s.group('comp.lang.python') >>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last @@ -35,12 +35,12 @@ Group comp.lang.python has 59 articles, range 3742 to 3803 >>> s.quit() '205 news.cwi.nl closing connection. Goodbye.' >>> -\end{verbatim}\ecode +\end{verbatim} To post an article from a file (this assumes that the article has valid headers): -\bcode\begin{verbatim} +\begin{verbatim} >>> s = NNTP('news.cwi.nl') >>> f = open('/tmp/article') >>> s.post(f) @@ -48,7 +48,7 @@ valid headers): >>> s.quit() '205 news.cwi.nl closing connection. Goodbye.' >>> -\end{verbatim}\ecode +\end{verbatim} % The module itself defines the following items: @@ -83,7 +83,7 @@ is the server's response: a string beginning with a three-digit code. If the server's response indicates an error, the method raises one of the above exceptions. -\renewcommand{\indexsubitem}{(NNTP object method)} +\setindexsubitem{(NNTP object method)} \begin{funcdesc}{getwelcome}{} Return the welcome message sent by the server in reply to the initial diff --git a/Doc/lib/liboperator.tex b/Doc/lib/liboperator.tex index 190faab..d371ee3 100644 --- a/Doc/lib/liboperator.tex +++ b/Doc/lib/liboperator.tex @@ -11,7 +11,7 @@ leading and trailing \samp{__} are also provided for convenience. The \code{operator} module defines the following functions: -\renewcommand{\indexsubitem}{(in module operator)} +\setindexsubitem{(in module operator)} \begin{funcdesc}{add}{a, b} Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers. @@ -188,10 +188,10 @@ Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}. Example: Build a dictionary that maps the ordinals from \code{0} to \code{256} to their character equivalents. -\bcode\begin{verbatim} +\begin{verbatim} >>> import operator >>> d = {} >>> keys = range(256) >>> vals = map(chr, keys) >>> map(operator.setitem, [d]*len(keys), keys, vals) -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex index 763d2f3..58f268c 100644 --- a/Doc/lib/libos.tex +++ b/Doc/lib/libos.tex @@ -26,7 +26,7 @@ directly from the OS dependent built-in module, so there should be In addition to whatever the correct OS dependent module exports, the following variables and functions are always exported by \code{os}: -\renewcommand{\indexsubitem}{(in module os)} +\setindexsubitem{(in module os)} \begin{datadesc}{name} The name of the OS dependent module imported. The following names diff --git a/Doc/lib/libpanel.tex b/Doc/lib/libpanel.tex index c546412..efcfd0e 100644 --- a/Doc/lib/libpanel.tex +++ b/Doc/lib/libpanel.tex @@ -15,7 +15,7 @@ to interface with the The module is too large to document here in its entirety. One interesting function: -\renewcommand{\indexsubitem}{(in module panel)} +\setindexsubitem{(in module panel)} \begin{funcdesc}{defpanellist}{filename} Parses a panel description file containing S-expressions written by the \emph{Panel Editor} diff --git a/Doc/lib/libparser.tex b/Doc/lib/libparser.tex index 4b838c5..47b5bd4 100644 --- a/Doc/lib/libparser.tex +++ b/Doc/lib/libparser.tex @@ -89,7 +89,7 @@ to convert AST objects to other representations such as parse trees and compiled code objects, but there are also functions which serve to query the type of parse tree represented by an AST object. -\renewcommand{\indexsubitem}{(in module parser)} +\setindexsubitem{(in module parser)} \subsection{Creating AST Objects} @@ -289,30 +289,30 @@ bytecode generation, the simplest operation is to do nothing. For this purpose, using the \module{parser} module to produce an intermediate data structure is equivelent to the code -\bcode\begin{verbatim} +\begin{verbatim} >>> code = compile('a + 5', 'eval') >>> a = 5 >>> eval(code) 10 -\end{verbatim}\ecode +\end{verbatim} % The equivelent operation using the \module{parser} module is somewhat longer, and allows the intermediate internal parse tree to be retained as an AST object: -\bcode\begin{verbatim} +\begin{verbatim} >>> import parser >>> ast = parser.expr('a + 5') >>> code = parser.compileast(ast) >>> a = 5 >>> eval(code) 10 -\end{verbatim}\ecode +\end{verbatim} % An application which needs both AST and code objects can package this code into readily available functions: -\bcode\begin{verbatim} +\begin{verbatim} import parser def load_suite(source_string): @@ -324,7 +324,7 @@ def load_expression(source_string): ast = parser.expr(source_string) code = parser.compileast(ast) return ast, code -\end{verbatim}\ecode +\end{verbatim} % \subsubsection{Information Discovery} @@ -367,16 +367,16 @@ Consider the simplest case of interest when searching for docstrings: a module consisting of a docstring and nothing else. (See file \file{docstring.py}.) -\bcode\begin{verbatim} +\begin{verbatim} """Some documentation. """ -\end{verbatim}\ecode +\end{verbatim} % Using the interpreter to take a look at the parse tree, we find a bewildering mass of numbers and parentheses, with the documentation buried deep in nested tuples. -\bcode\begin{verbatim} +\begin{verbatim} >>> import parser >>> import pprint >>> ast = parser.suite(open('docstring.py').read()) @@ -404,7 +404,7 @@ buried deep in nested tuples. (4, ''))), (4, ''), (0, '')) -\end{verbatim}\ecode +\end{verbatim} % The numbers at the first element of each node in the tree are the node types; they map directly to terminal and non-terminal symbols in the @@ -444,7 +444,7 @@ form, allowing a simple variable representation to be the pattern matching, returning a boolean and a dictionary of variable name to value mappings. (See file \file{example.py}.) -\bcode\begin{verbatim} +\begin{verbatim} from types import ListType, TupleType def match(pattern, data, vars=None): @@ -462,13 +462,13 @@ def match(pattern, data, vars=None): if not same: break return same, vars -\end{verbatim}\ecode +\end{verbatim} % Using this simple representation for syntactic variables and the symbolic node types, the pattern for the candidate docstring subtrees becomes fairly readable. (See file \file{example.py}.) -\bcode\begin{verbatim} +\begin{verbatim} import symbol import token @@ -495,18 +495,18 @@ DOCSTRING_STMT_PATTERN = ( )))))))))))))))), (token.NEWLINE, '') )) -\end{verbatim}\ecode +\end{verbatim} % Using the \function{match()} function with this pattern, extracting the module docstring from the parse tree created previously is easy: -\bcode\begin{verbatim} +\begin{verbatim} >>> found, vars = match(DOCSTRING_STMT_PATTERN, tup[1]) >>> found 1 >>> vars {'docstring': '"""Some documentation.\012"""'} -\end{verbatim}\ecode +\end{verbatim} % Once specific data can be extracted from a location where it is expected, the question of where information can be expected @@ -569,7 +569,7 @@ grammar, but the method which recursively creates new information objects requires further examination. Here is the relevant part of the \class{SuiteInfoBase} definition from \file{example.py}: -\bcode\begin{verbatim} +\begin{verbatim} class SuiteInfoBase: _docstring = '' _name = '' @@ -599,7 +599,7 @@ class SuiteInfoBase: elif cstmt[0] == symbol.classdef: name = cstmt[2][1] self._class_info[name] = ClassInfo(cstmt) -\end{verbatim}\ecode +\end{verbatim} % After initializing some internal state, the constructor calls the \method{_extract_info()} method. This method performs the bulk of the @@ -620,13 +620,13 @@ def square(x): "Square an argument."; return x ** 2 while the long form uses an indented block and allows nested definitions: -\bcode\begin{verbatim} +\begin{verbatim} def make_power(exp): "Make a function that raises an argument to the exponent `exp'." def raiser(x, y=exp): return x ** y return raiser -\end{verbatim}\ecode +\end{verbatim} % When the short form is used, the code block may contain a docstring as the first, and possibly only, \constant{small_stmt} element. The @@ -662,7 +662,7 @@ the real extraction algorithm remains common to all forms of code blocks. A high-level function can be used to extract the complete set of information from a source file. (See file \file{example.py}.) -\bcode\begin{verbatim} +\begin{verbatim} def get_docs(fileName): source = open(fileName).read() import os @@ -671,7 +671,7 @@ def get_docs(fileName): ast = parser.suite(source) tup = parser.ast2tuple(ast) return ModuleInfo(tup, basename) -\end{verbatim}\ecode +\end{verbatim} % This provides an easy-to-use interface to the documentation of a module. If information is required which is not extracted by the code @@ -703,7 +703,7 @@ to may change between Python versions. This module also provides one additional data object: -\renewcommand{\indexsubitem}{(in module symbol)} +\setindexsubitem{(in module symbol)} \begin{datadesc}{sym_name} @@ -731,7 +731,7 @@ versions. This module also provides one data object and some functions. The functions mirror definitions in the Python C header files. -\renewcommand{\indexsubitem}{(in module token)} +\setindexsubitem{(in module token)} \begin{datadesc}{tok_name} diff --git a/Doc/lib/libpdb.tex b/Doc/lib/libpdb.tex index b2db2a2..6f14ab6 100644 --- a/Doc/lib/libpdb.tex +++ b/Doc/lib/libpdb.tex @@ -2,7 +2,7 @@ \stmodindex{pdb} \index{debugging} -\renewcommand{\indexsubitem}{(in module pdb)} +\setindexsubitem{(in module pdb)} The module \code{pdb} defines an interactive source code debugger for Python programs. It supports setting @@ -29,7 +29,7 @@ specific modules). The debugger's prompt is ``\code{(Pdb) }''. Typical usage to run a program under control of the debugger is: -\bcode\begin{verbatim} +\begin{verbatim} >>> import pdb >>> import mymodule >>> pdb.run('mymodule.test()') @@ -40,7 +40,7 @@ Typical usage to run a program under control of the debugger is: NameError: 'spam' > <string>(1)?() (Pdb) -\end{verbatim}\ecode +\end{verbatim} % \code{pdb.py} can also be invoked as a script to debug other scripts. For example: @@ -48,7 +48,7 @@ a script to debug other scripts. For example: Typical usage to inspect a crashed program is: -\bcode\begin{verbatim} +\begin{verbatim} >>> import pdb >>> import mymodule >>> mymodule.test() @@ -63,7 +63,7 @@ NameError: spam > ./mymodule.py(3)test2() -> print spam (Pdb) -\end{verbatim}\ecode +\end{verbatim} % The module defines the following functions; each enters the debugger in a slightly different way: @@ -224,10 +224,10 @@ The exclamation point can be omitted unless the first word of the statement resembles a debugger command. To set a global variable, you can prefix the assignment command with a ``\code{global}'' command on the same line, e.g.: -\bcode\begin{verbatim} +\begin{verbatim} (Pdb) global list_options; list_options = ['-l'] (Pdb) -\end{verbatim}\ecode +\end{verbatim} % \item[q(uit)] diff --git a/Doc/lib/libpickle.tex b/Doc/lib/libpickle.tex index 5eef11c..41191d4 100644 --- a/Doc/lib/libpickle.tex +++ b/Doc/lib/libpickle.tex @@ -8,7 +8,7 @@ \indexii{flattening}{objects} \indexii{pickling}{objects} -\renewcommand{\indexsubitem}{(in module pickle)} +\setindexsubitem{(in module pickle)} The \code{pickle} module implements a basic but powerful algorithm for ``pickling'' (a.k.a.\ serializing, marshalling or flattening) nearly @@ -94,7 +94,7 @@ There are some restrictions on the pickling of class instances. First of all, the class must be defined at the top level in a module. Furthermore, all its instance variables must be picklable. -\renewcommand{\indexsubitem}{(pickle protocol)} +\setindexsubitem{(pickle protocol)} When a pickled class instance is unpickled, its \code{__init__()} method is normally \emph{not} invoked. \strong{Note:} This is a deviation @@ -144,35 +144,35 @@ definition is not pickled, but re-imported by the unpickling process. Therefore, the restriction that the class must be defined at the top level in a module applies to pickled classes as well. -\renewcommand{\indexsubitem}{(in module pickle)} +\setindexsubitem{(in module pickle)} The interface can be summarized as follows. To pickle an object \code{x} onto a file \code{f}, open for writing: -\bcode\begin{verbatim} +\begin{verbatim} p = pickle.Pickler(f) p.dump(x) -\end{verbatim}\ecode +\end{verbatim} % A shorthand for this is: -\bcode\begin{verbatim} +\begin{verbatim} pickle.dump(x, f) -\end{verbatim}\ecode +\end{verbatim} % To unpickle an object \code{x} from a file \code{f}, open for reading: -\bcode\begin{verbatim} +\begin{verbatim} u = pickle.Unpickler(f) x = u.load() -\end{verbatim}\ecode +\end{verbatim} % A shorthand is: -\bcode\begin{verbatim} +\begin{verbatim} x = pickle.load(f) -\end{verbatim}\ecode +\end{verbatim} % The \code{Pickler} class only calls the method \code{f.write()} with a string argument. The \code{Unpickler} calls the methods \code{f.read()} diff --git a/Doc/lib/libposix.tex b/Doc/lib/libposix.tex index ddd467b..1754fef 100644 --- a/Doc/lib/libposix.tex +++ b/Doc/lib/libposix.tex @@ -28,7 +28,7 @@ for type errors, while errors reported by the system calls raise Module \code{posix} defines the following data items: -\renewcommand{\indexsubitem}{(data in module posix)} +\setindexsubitem{(data in module posix)} \begin{datadesc}{environ} A dictionary representing the string environment at the time the interpreter was started. @@ -50,7 +50,7 @@ a mapping object that behaves almost like a dictionary but invokes \code{putenv()} automatically called whenever an item is changed. \end{datadesc} -\renewcommand{\indexsubitem}{(exception in module posix)} +\setindexsubitem{(exception in module posix)} \begin{excdesc}{error} This exception is raised when a \POSIX{} function returns a \POSIX{}-related error (e.g., not for illegal argument types). Its @@ -64,7 +64,7 @@ names for the error codes defined by the underlying operating system. It defines the following functions and constants: -\renewcommand{\indexsubitem}{(in module posix)} +\setindexsubitem{(in module posix)} \begin{funcdesc}{chdir}{path} Change the current working directory to \var{path}. \end{funcdesc} diff --git a/Doc/lib/libposixfile.tex b/Doc/lib/libposixfile.tex index 3d1fad1..fc04d8d 100644 --- a/Doc/lib/libposixfile.tex +++ b/Doc/lib/libposixfile.tex @@ -21,7 +21,7 @@ the same as a standard file object. The posixfile module defines the following constants: -\renewcommand{\indexsubitem}{(in module posixfile)} +\setindexsubitem{(in module posixfile)} \begin{datadesc}{SEEK_SET} offset is calculated from the start of the file \end{datadesc} @@ -36,7 +36,7 @@ offset is calculated from the end of the file The posixfile module defines the following functions: -\renewcommand{\indexsubitem}{(in module posixfile)} +\setindexsubitem{(in module posixfile)} \begin{funcdesc}{open}{filename\optional{\, mode\optional{\, bufsize}}} Create a new posixfile object with the given filename and mode. The @@ -52,7 +52,7 @@ The posixfile module defines the following functions: The posixfile object defines the following additional methods: -\renewcommand{\indexsubitem}{(posixfile method)} +\setindexsubitem{(posixfile method)} \begin{funcdesc}{lock}{fmt\, \optional{len\optional{\, start\optional{\, whence}}}} Lock the specified section of the file that the file object is referring to. The format is explained @@ -146,7 +146,7 @@ by the same call. Examples: -\bcode\begin{verbatim} +\begin{verbatim} from posixfile import * file = open('/tmp/test', 'w') @@ -154,4 +154,4 @@ file.lock('w|') ... file.lock('u') file.close() -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libppath.tex b/Doc/lib/libppath.tex index 5298012..d286dcc 100644 --- a/Doc/lib/libppath.tex +++ b/Doc/lib/libppath.tex @@ -8,7 +8,7 @@ This module implements some useful functions on \POSIX{} pathnames. module \code{os} and use \code{os.path}. \refstmodindex{os} -\renewcommand{\indexsubitem}{(in module posixpath)} +\setindexsubitem{(in module posixpath)} \begin{funcdesc}{basename}{p} Return the base name of pathname diff --git a/Doc/lib/libpprint.tex b/Doc/lib/libpprint.tex index 9e14d5f..caae69a 100644 --- a/Doc/lib/libpprint.tex +++ b/Doc/lib/libpprint.tex @@ -19,7 +19,7 @@ to adjust the width constraint. The \code{pprint} module defines one class: -\renewcommand{\indexsubitem}{(in module pprint)} +\setindexsubitem{(in module pprint)} % First the implementation class: @@ -140,7 +140,7 @@ l/lib/python1.4/test', '/usr/local/lib/python1.4/sunos5', '/usr/local/lib/python PrettyPrinter instances (returned by \code{PrettyPrinter()} above) have the following methods. -\renewcommand{\indexsubitem}{(PrettyPrinter method)} +\setindexsubitem{(PrettyPrinter method)} \begin{funcdesc}{pformat}{object} Return the formatted representation of \var{object}. This takes into diff --git a/Doc/lib/libprofile.tex b/Doc/lib/libprofile.tex index a333744..20da0b6 100644 --- a/Doc/lib/libprofile.tex +++ b/Doc/lib/libprofile.tex @@ -106,10 +106,10 @@ rapidly perform profiling on an existing application. To profile an application with a main entry point of \samp{foo()}, you would add the following to your module: -\bcode\begin{verbatim} +\begin{verbatim} import profile profile.run("foo()") -\end{verbatim}\ecode +\end{verbatim} % The above action would cause \samp{foo()} to be run, and a series of informative lines (the profile) to be printed. The above approach is @@ -118,10 +118,10 @@ save the results of a profile into a file for later examination, you can supply a file name as the second argument to the \code{run()} function: -\bcode\begin{verbatim} +\begin{verbatim} import profile profile.run("foo()", 'fooprof') -\end{verbatim}\ecode +\end{verbatim} % \code{profile.py} can also be invoked as a script to profile another script. For example: @@ -131,10 +131,10 @@ When you wish to review the profile, you should use the methods in the \code{pstats} module. Typically you would load the statistics data as follows: -\bcode\begin{verbatim} +\begin{verbatim} import pstats p = pstats.Stats('fooprof') -\end{verbatim}\ecode +\end{verbatim} % The class \code{Stats} (the above code just created an instance of this class) has a variety of methods for manipulating and printing the @@ -142,9 +142,9 @@ data that was just read into \samp{p}. When you ran \code{profile.run()} above, what was printed was the result of three method calls: -\bcode\begin{verbatim} +\begin{verbatim} p.strip_dirs().sort_stats(-1).print_stats() -\end{verbatim}\ecode +\end{verbatim} % The first method removed the extraneous path from all the module names. The second method sorted all the entries according to the @@ -152,18 +152,18 @@ standard module/line/name string that is printed (this is to comply with the semantics of the old profiler). The third method printed out all the statistics. You might try the following sort calls: -\bcode\begin{verbatim} +\begin{verbatim} p.sort_stats('name') p.print_stats() -\end{verbatim}\ecode +\end{verbatim} % The first call will actually sort the list by function name, and the second call will print out the statistics. The following are some interesting calls to experiment with: -\bcode\begin{verbatim} +\begin{verbatim} p.sort_stats('cumulative').print_stats(10) -\end{verbatim}\ecode +\end{verbatim} % This sorts the profile by cumulative time in a function, and then only prints the ten most significant lines. If you want to understand what @@ -172,26 +172,26 @@ algorithms are taking time, the above line is what you would use. If you were looking to see what functions were looping a lot, and taking a lot of time, you would do: -\bcode\begin{verbatim} +\begin{verbatim} p.sort_stats('time').print_stats(10) -\end{verbatim}\ecode +\end{verbatim} % to sort according to time spent within each function, and then print the statistics for the top ten functions. You might also try: -\bcode\begin{verbatim} +\begin{verbatim} p.sort_stats('file').print_stats('__init__') -\end{verbatim}\ecode +\end{verbatim} % This will sort all the statistics by file name, and then print out statistics for only the class init methods ('cause they are spelled with \code{__init__} in them). As one final example, you could try: -\bcode\begin{verbatim} +\begin{verbatim} p.sort_stats('time', 'cum').print_stats(.5, 'init') -\end{verbatim}\ecode +\end{verbatim} % This line sorts statistics with a primary key of time, and a secondary key of cumulative time, and then prints out some of the statistics. @@ -202,19 +202,19 @@ maintained, and that sub-sub-list is printed. If you wondered what functions called the above functions, you could now (\samp{p} is still sorted according to the last criteria) do: -\bcode\begin{verbatim} +\begin{verbatim} p.print_callers(.5, 'init') -\end{verbatim}\ecode +\end{verbatim} % and you would get a list of callers for each of the listed functions. If you want more functionality, you're going to have to read the manual, or guess what the following functions do: -\bcode\begin{verbatim} +\begin{verbatim} p.print_callees() p.add('fooprof') -\end{verbatim}\ecode +\end{verbatim} % \section{What Is Deterministic Profiling?} \nodename{Deterministic Profiling} @@ -251,7 +251,7 @@ of algorithms to be directly compared to iterative implementations. \section{Reference Manual} -\renewcommand{\indexsubitem}{(profiler function)} +\setindexsubitem{(profiler function)} The primary entry point for the profiler is the global function \code{profile.run()}. It is typically used to create any profile @@ -273,7 +273,7 @@ function automatically prints a simple profiling report, sorted by the standard name string (file/line/function-name) that is presented in each line. The following is a typical output from such a call: -\bcode\begin{verbatim} +\begin{verbatim} main() 2706 function calls (2004 primitive calls) in 4.504 CPU seconds @@ -283,7 +283,7 @@ ncalls tottime percall cumtime percall filename:lineno(function) 2 0.006 0.003 0.953 0.477 pobject.py:75(save_objects) 43/3 0.533 0.012 0.749 0.250 pobject.py:99(evaluate) ... -\end{verbatim}\ecode +\end{verbatim} The first line indicates that this profile was generated by the call:\\ \code{profile.run('main()')}, and hence the exec'ed string is @@ -348,7 +348,7 @@ need to be combined with data in an existing \code{Stats} object, the \subsection{The \sectcode{Stats} Class} -\renewcommand{\indexsubitem}{(Stats method)} +\setindexsubitem{(Stats method)} \begin{funcdesc}{strip_dirs}{} This method for the \code{Stats} class removes all leading path information @@ -447,17 +447,17 @@ Python 1.5b1, this uses the Perl-style regular expression syntax defined by the \code{re} module). If several restrictions are provided, then they are applied sequentially. For example: -\bcode\begin{verbatim} +\begin{verbatim} print_stats(.1, "foo:") -\end{verbatim}\ecode +\end{verbatim} % would first limit the printing to first 10\% of list, and then only print functions that were part of filename \samp{.*foo:}. In contrast, the command: -\bcode\begin{verbatim} +\begin{verbatim} print_stats("foo:", .1) -\end{verbatim}\ecode +\end{verbatim} % would limit the list to all functions having file names \samp{.*foo:}, and then proceed to only print the first 10\% of them. @@ -487,10 +487,10 @@ returned by earlier methods. All standard methods in this class return the instance that is being processed, so that the commands can be strung together. For example: -\bcode\begin{verbatim} +\begin{verbatim} pstats.Stats('foofile').strip_dirs().sort_stats('cum') \ .print_stats().ignore() -\end{verbatim}\ecode +\end{verbatim} % would perform all the indicated functions, but it would not return the final reference to the \code{Stats} instance.% @@ -551,27 +551,27 @@ function, and socking away the results. The following procedure can be used to obtain this constant for a given platform (see discussion in section Limitations above). -\bcode\begin{verbatim} +\begin{verbatim} import profile pr = profile.Profile() pr.calibrate(100) pr.calibrate(100) pr.calibrate(100) -\end{verbatim}\ecode +\end{verbatim} % The argument to calibrate() is the number of times to try to do the sample calls to get the CPU times. If your computer is \emph{very} fast, you might have to do: -\bcode\begin{verbatim} +\begin{verbatim} pr.calibrate(1000) -\end{verbatim}\ecode +\end{verbatim} % or even: -\bcode\begin{verbatim} +\begin{verbatim} pr.calibrate(10000) -\end{verbatim}\ecode +\end{verbatim} % The object of this exercise is to get a fairly consistent result. When you have a consistent answer, you are ready to use that number in @@ -584,7 +584,7 @@ The following shows how the trace_dispatch() method in the Profile class should be modified to install the calibration constant on a Sun Sparcstation 1000: -\bcode\begin{verbatim} +\begin{verbatim} def trace_dispatch(self, frame, event, arg): t = self.timer() t = t[0] + t[1] - self.t - .00053 # Calibration constant @@ -596,14 +596,14 @@ def trace_dispatch(self, frame, event, arg): r = self.timer() self.t = r[0] + r[1] - t # put back unrecorded delta return -\end{verbatim}\ecode +\end{verbatim} % Note that if there is no calibration constant, then the line containing the callibration constant should simply say: -\bcode\begin{verbatim} +\begin{verbatim} t = t[0] + t[1] - self.t # no calibration constant -\end{verbatim}\ecode +\end{verbatim} % You can also achieve the same results using a derived class (and the profiler will actually run equally fast!!), but the above method is @@ -632,9 +632,9 @@ timer function is used, then the basic class has an option for that in the constructor for the class. Consider passing the name of a function to call into the constructor: -\bcode\begin{verbatim} +\begin{verbatim} pr = profile.Profile(your_time_func) -\end{verbatim}\ecode +\end{verbatim} % The resulting profiler will call \code{your_time_func()} instead of \code{os.times()}. The function should return either a single number @@ -664,7 +664,7 @@ stats, and is quite useful when there is \emph{no} recursion in the user's code. It is also a lot more accurate than the old profiler, as it does not charge all its overhead time to the user's code. -\bcode\begin{verbatim} +\begin{verbatim} class OldProfile(Profile): def trace_dispatch_exception(self, frame, t): @@ -714,7 +714,7 @@ class OldProfile(Profile): callers[func_caller] nc = nc + callers[func_caller] self.stats[nor_func] = nc, nc, tt, ct, nor_callers -\end{verbatim}\ecode +\end{verbatim} % \subsection{HotProfile Class} @@ -725,7 +725,7 @@ function, so it runs very quickly (re: very low overhead). In truth, the basic profiler is so fast, that is probably not worth the savings to give up the data, but this class still provides a nice example. -\bcode\begin{verbatim} +\begin{verbatim} class HotProfile(Profile): def trace_dispatch_exception(self, frame, t): @@ -761,4 +761,4 @@ class HotProfile(Profile): nc, tt = self.timings[func] nor_func = self.func_normalize(func) self.stats[nor_func] = nc, nc, tt, 0, {} -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libpwd.tex b/Doc/lib/libpwd.tex index 82ebd61..8e1fd2b 100644 --- a/Doc/lib/libpwd.tex +++ b/Doc/lib/libpwd.tex @@ -19,7 +19,7 @@ A \code{KeyError} exception is raised if the entry asked for cannot be found. It defines the following items: -\renewcommand{\indexsubitem}{(in module pwd)} +\setindexsubitem{(in module pwd)} \begin{funcdesc}{getpwuid}{uid} Return the password database entry for the given numeric user ID. \end{funcdesc} diff --git a/Doc/lib/libqueue.tex b/Doc/lib/libqueue.tex index 43f48ac..f6aa31e 100644 --- a/Doc/lib/libqueue.tex +++ b/Doc/lib/libqueue.tex @@ -18,7 +18,7 @@ Python. The \code{Queue} module defines the following exception: -\renewcommand{\indexsubitem}{(in module Queue)} +\setindexsubitem{(in module Queue)} \begin{excdesc}{Empty} Exception raised when non-blocking get (e.g. \code{get_nowait()}) is @@ -35,7 +35,7 @@ other queue organizations (e.g. stack) but the inheritable interface is not described here. See the source code for details. The public interface methods are: -\renewcommand{\indexsubitem}{(__init__ method)} +\setindexsubitem{(__init__ method)} \begin{funcdesc}{__init__}{maxsize} Constructor for the class. \var{maxsize} is an integer that sets the @@ -45,41 +45,41 @@ queue items are consumed. If \var{maxsize} is less than or equal to zero, the queue size is infinite. \end{funcdesc} -\renewcommand{\indexsubitem}{(qsize method)} +\setindexsubitem{(qsize method)} \begin{funcdesc}{qsize}{} Returns the approximate size of the queue. Because of multithreading semantics, this number is not reliable. \end{funcdesc} -\renewcommand{\indexsubitem}{(empty method)} +\setindexsubitem{(empty method)} \begin{funcdesc}{empty}{} Returns 1 if the queue is empty, 0 otherwise. Because of multithreading semantics, this is not reliable. \end{funcdesc} -\renewcommand{\indexsubitem}{(full method)} +\setindexsubitem{(full method)} \begin{funcdesc}{full}{} Returns 1 if the queue is full, 0 otherwise. Because of multithreading semantics, this is not reliable. \end{funcdesc} -\renewcommand{\indexsubitem}{(put method)} +\setindexsubitem{(put method)} \begin{funcdesc}{put}{item} Puts \var{item} into the queue. \end{funcdesc} -\renewcommand{\indexsubitem}{(get method)} +\setindexsubitem{(get method)} \begin{funcdesc}{get}{} Gets and returns an item from the queue, blocking if necessary until one is available. \end{funcdesc} -\renewcommand{\indexsubitem}{(get_nowait method)} +\setindexsubitem{(get_nowait method)} \begin{funcdesc}{get_nowait}{} Gets and returns an item from the queue if one is immediately diff --git a/Doc/lib/libquopri.tex b/Doc/lib/libquopri.tex index d1cb297..4ad0c0f 100644 --- a/Doc/lib/libquopri.tex +++ b/Doc/lib/libquopri.tex @@ -11,7 +11,7 @@ are many such characters, as when sending a graphics file. \indexii{quoted printable}{encoding} \index{MIME!quoted-printable encoding} -\renewcommand{\indexsubitem}{(in module quopri)} +\setindexsubitem{(in module quopri)} \begin{funcdesc}{decode}{input\, output} Decode the contents of the \var{input} file and write the resulting diff --git a/Doc/lib/librand.tex b/Doc/lib/librand.tex index 4ba5f17..07d309e 100644 --- a/Doc/lib/librand.tex +++ b/Doc/lib/librand.tex @@ -8,7 +8,7 @@ given library's implementation. While still supported for compatibility, the \code{rand} module is now considered obsolete; if possible, use the \code{whrandom} module instead. -\renewcommand{\indexsubitem}{(in module rand)} +\setindexsubitem{(in module rand)} \begin{funcdesc}{choice}{seq} Returns a random element from the sequence \var{seq}. diff --git a/Doc/lib/librandom.tex b/Doc/lib/librandom.tex index 7b29092..ab4527f 100644 --- a/Doc/lib/librandom.tex +++ b/Doc/lib/librandom.tex @@ -19,7 +19,7 @@ after the corresponding variables in the distribution's equation, as used in common mathematical practice; most of these equations can be found in any statistics text. -\renewcommand{\indexsubitem}{(in module random)} +\setindexsubitem{(in module random)} \begin{funcdesc}{betavariate}{alpha\, beta} Beta distribution. Conditions on the parameters are \code{alpha>-1} and \code{beta>-1}. diff --git a/Doc/lib/libre.tex b/Doc/lib/libre.tex index 3c288d1..55125ec 100644 --- a/Doc/lib/libre.tex +++ b/Doc/lib/libre.tex @@ -258,7 +258,7 @@ for the current locale. The module defines the following functions and constants, and an exception: -\renewcommand{\indexsubitem}{(in module re)} +\setindexsubitem{(in module re)} \begin{funcdesc}{compile}{pattern\optional{\, flags}} Compile a regular expression pattern into a regular expression @@ -313,10 +313,10 @@ leftmost such \code{\#} through the end of the line are ignored. The sequence % -\bcode\begin{verbatim} +\begin{verbatim} prog = re.compile(pat) result = prog.match(str) -\end{verbatim}\ecode +\end{verbatim} % is equivalent to @@ -365,14 +365,14 @@ expression will be used several times in a single program. 1.5 release, \var{maxsplit} was ignored. This has been fixed in later releases.) % -\bcode\begin{verbatim} +\begin{verbatim} >>> re.split('[\W]+', 'Words, words, words.') ['Words', 'words', 'words', ''] >>> re.split('([\W]+)', 'Words, words, words.') ['Words', ', ', 'words', ', ', 'words', '.', ''] >>> re.split('[\W]+', 'Words, words, words.', 1) ['Words', 'words, words.'] -\end{verbatim}\ecode +\end{verbatim} % This function combines and extends the functionality of the old \code{regsub.split()} and \code{regsub.splitx()}. @@ -387,13 +387,13 @@ it is called for every non-overlapping occurance of \var{pattern}. The function takes a single match object argument, and returns the replacement string. For example: % -\bcode\begin{verbatim} +\begin{verbatim} >>> def dashrepl(matchobj): ... if matchobj.group(0) == '-': return ' ' ... else: return '-' >>> re.sub('-{1,2}', dashrepl, 'pro----gram-files') 'pro--gram files' -\end{verbatim}\ecode +\end{verbatim} % The pattern may be a string or a regex object; if you need to specify @@ -428,7 +428,7 @@ Perform the same operation as \code{sub()}, but return a tuple Compiled regular expression objects support the following methods and attributes: -\renewcommand{\indexsubitem}{(re method)} +\setindexsubitem{(re method)} \begin{funcdesc}{match}{string\optional{\, pos}\optional{\, endpos}} If zero or more characters at the beginning of \var{string} match this regular expression, return a corresponding @@ -469,7 +469,7 @@ Identical to the \code{sub()} function, using the compiled pattern. Identical to the \code{subn()} function, using the compiled pattern. \end{funcdesc} -\renewcommand{\indexsubitem}{(regex attribute)} +\setindexsubitem{(regex attribute)} \begin{datadesc}{flags} The flags argument used when the regex object was compiled, or 0 if no diff --git a/Doc/lib/libregex.tex b/Doc/lib/libregex.tex index 00005e2..18b8b18 100644 --- a/Doc/lib/libregex.tex +++ b/Doc/lib/libregex.tex @@ -186,7 +186,7 @@ the string. The module defines these functions, and an exception: -\renewcommand{\indexsubitem}{(in module regex)} +\setindexsubitem{(in module regex)} \begin{funcdesc}{match}{pattern\, string} Return how many characters at the beginning of \var{string} match @@ -215,16 +215,16 @@ The module defines these functions, and an exception: The sequence -\bcode\begin{verbatim} +\begin{verbatim} prog = regex.compile(pat) result = prog.match(str) -\end{verbatim}\ecode +\end{verbatim} % is equivalent to -\bcode\begin{verbatim} +\begin{verbatim} result = regex.match(pat, str) -\end{verbatim}\ecode +\end{verbatim} but the version using \code{compile()} is more efficient when multiple regular expressions are used concurrently in a single program. (The @@ -274,7 +274,7 @@ equivalents. \noindent Compiled regular expression objects support these methods: -\renewcommand{\indexsubitem}{(regex method)} +\setindexsubitem{(regex method)} \begin{funcdesc}{match}{string\optional{\, pos}} Return how many characters at the beginning of \var{string} match the compiled regular expression. Return \code{-1} if the string @@ -319,7 +319,7 @@ identifying groups by their group name. \noindent Compiled regular expressions support these data attributes: -\renewcommand{\indexsubitem}{(regex attribute)} +\setindexsubitem{(regex attribute)} \begin{datadesc}{regs} When the last call to the \code{match()} or \code{search()} method found a diff --git a/Doc/lib/libregsub.tex b/Doc/lib/libregsub.tex index 48cff87..5158d53 100644 --- a/Doc/lib/libregsub.tex +++ b/Doc/lib/libregsub.tex @@ -18,7 +18,7 @@ expressions to \module{re} style regular expressions. (For more conversion help, see the URL \url{http://starship.skyport.net/crew/amk/regex/regex-to-re.html}.) -\renewcommand{\indexsubitem}{(in module regsub)} +\setindexsubitem{(in module regsub)} \begin{funcdesc}{sub}{pat\, repl\, str} Replace the first occurrence of pattern \var{pat} in string diff --git a/Doc/lib/libresource.tex b/Doc/lib/libresource.tex index 7af4368..6260a20 100644 --- a/Doc/lib/libresource.tex +++ b/Doc/lib/libresource.tex @@ -11,7 +11,7 @@ children. A single exception is defined for errors: -\renewcommand{\indexsubitem}{(in module resource)} +\setindexsubitem{(in module resource)} \begin{excdesc}{error} The functions described below may raise this error if the underlying diff --git a/Doc/lib/librexec.tex b/Doc/lib/librexec.tex index 742e32b..4ea3f3c 100644 --- a/Doc/lib/librexec.tex +++ b/Doc/lib/librexec.tex @@ -1,60 +1,60 @@ \section{Standard Module \sectcode{rexec}} \label{module-rexec} \stmodindex{rexec} -\renewcommand{\indexsubitem}{(in module rexec)} +\setindexsubitem{(in module rexec)} -This module contains the \code{RExec} class, which supports +This module contains the \class{RExec} class, which supports \code{r_exec()}, \code{r_eval()}, \code{r_execfile()}, and \code{r_import()} methods, which are restricted versions of the standard Python functions \code{exec()}, \code{eval()}, \code{execfile()}, and the \code{import} statement. Code executed in this restricted environment will only have access to modules and functions that are deemed safe; you -can subclass \code{RExec} to add or remove capabilities as desired. +can subclass \class{RExec} to add or remove capabilities as desired. -\emph{Note:} The \code{RExec} class can prevent code from performing +\emph{Note:} The \class{RExec} class can prevent code from performing unsafe operations like reading or writing disk files, or using TCP/IP sockets. However, it does not protect against code using extremely large amounts of memory or CPU time. \begin{funcdesc}{RExec}{\optional{hooks\optional{\, verbose}}} -Returns an instance of the \code{RExec} class. +Returns an instance of the \class{RExec} class. \var{hooks} is an instance of the \code{RHooks} class or a subclass of it. If it is omitted or \code{None}, the default \code{RHooks} class is instantiated. -Whenever the RExec module searches for a module (even a built-in one) -or reads a module's code, it doesn't actually go out to the file -system itself. Rather, it calls methods of an RHooks instance that -was passed to or created by its constructor. (Actually, the RExec -object doesn't make these calls---they are made by a module loader -object that's part of the RExec object. This allows another level of -flexibility, e.g. using packages.) - -By providing an alternate RHooks object, we can control the +Whenever the \module{RExec} module searches for a module (even a +built-in one) or reads a module's code, it doesn't actually go out to +the file system itself. Rather, it calls methods of an \class{RHooks} +instance that was passed to or created by its constructor. (Actually, +the \class{RExec} object doesn't make these calls --- they are made by +a module loader object that's part of the \class{RExec} object. This +allows another level of flexibility, e.g. using packages.) + +By providing an alternate \class{RHooks} object, we can control the file system accesses made to import a module, without changing the actual algorithm that controls the order in which those accesses are -made. For instance, we could substitute an RHooks object that passes -all filesystem requests to a file server elsewhere, via some RPC -mechanism such as ILU. Grail's applet loader uses this to support +made. For instance, we could substitute an \class{RHooks} object that +passes all filesystem requests to a file server elsewhere, via some +RPC mechanism such as ILU. Grail's applet loader uses this to support importing applets from a URL for a directory. If \var{verbose} is true, additional debugging output may be sent to standard output. \end{funcdesc} -The RExec class has the following class attributes, which are used by the -\code{__init__} method. Changing them on an existing instance won't -have any effect; instead, create a subclass of \code{RExec} and assign -them new values in the class definition. Instances of the new class -will then use those new values. All these attributes are tuples of -strings. +The \class{RExec} class has the following class attributes, which are +used by the \code{__init__()} method. Changing them on an existing +instance won't have any effect; instead, create a subclass of +\class{RExec} and assign them new values in the class definition. +Instances of the new class will then use those new values. All these +attributes are tuples of strings. -\renewcommand{\indexsubitem}{(RExec object attribute)} +\setindexsubitem{(RExec object attribute)} \begin{datadesc}{nok_builtin_names} Contains the names of built-in functions which will \emph{not} be available to programs running in the restricted environment. The -value for \code{RExec} is \code{('open',} \code{'reload',} +value for \class{RExec} is \code{('open',} \code{'reload',} \code{'__import__')}. (This gives the exceptions, because by far the majority of built-in functions are harmless. A subclass that wants to override this variable should probably start with the value from the @@ -65,7 +65,7 @@ added to this module.) \begin{datadesc}{ok_builtin_modules} Contains the names of built-in modules which can be safely imported. -The value for \code{RExec} is \code{('audioop',} \code{'array',} +The value for \class{RExec} is \code{('audioop',} \code{'array',} \code{'binascii',} \code{'cmath',} \code{'errno',} \code{'imageop',} \code{'marshal',} \code{'math',} \code{'md5',} \code{'operator',} \code{'parser',} \code{'regex',} \code{'rotor',} \code{'select',} @@ -77,7 +77,7 @@ class as a starting point. \begin{datadesc}{ok_path} Contains the directories which will be searched when an \code{import} is performed in the restricted environment. -The value for \code{RExec} is the same as \code{sys.path} (at the time +The value for \class{RExec} is the same as \code{sys.path} (at the time the module is loaded) for unrestricted code. \end{datadesc} @@ -85,7 +85,7 @@ the module is loaded) for unrestricted code. % Should this be called ok_os_names? Contains the names of the functions in the \code{os} module which will be available to programs running in the restricted environment. The -value for \code{RExec} is \code{('error',} \code{'fstat',} +value for \class{RExec} is \code{('error',} \code{'fstat',} \code{'listdir',} \code{'lstat',} \code{'readlink',} \code{'stat',} \code{'times',} \code{'uname',} \code{'getpid',} \code{'getppid',} \code{'getcwd',} \code{'getuid',} \code{'getgid',} \code{'geteuid',} @@ -95,13 +95,13 @@ value for \code{RExec} is \code{('error',} \code{'fstat',} \begin{datadesc}{ok_sys_names} Contains the names of the functions and variables in the \code{sys} module which will be available to programs running in the restricted -environment. The value for \code{RExec} is \code{('ps1',} +environment. The value for \class{RExec} is \code{('ps1',} \code{'ps2',} \code{'copyright',} \code{'version',} \code{'platform',} \code{'exit',} \code{'maxint')}. \end{datadesc} -RExec instances support the following methods: -\renewcommand{\indexsubitem}{(RExec object method)} +\class{RExec} instances support the following methods: +\setindexsubitem{(RExec object method)} \begin{funcdesc}{r_eval}{code} \var{code} must either be a string containing a Python expression, or @@ -141,7 +141,7 @@ Execute the Python code contained in the file \var{filename} in the restricted environment. \end{funcdesc} -\code{RExec} objects must also support various methods which will be +\class{RExec} objects must also support various methods which will be implicitly called by code executing in the restricted environment. Overriding these methods in a subclass is used to change the policies enforced by a restricted environment. @@ -155,7 +155,7 @@ exception if the module is considered unsafe. Method called when \code{open()} is called in the restricted environment. The arguments are identical to those of \code{open()}, and a file object (or a class instance compatible with file objects) -should be returned. \code{RExec}'s default behaviour is allow opening +should be returned. \class{RExec}'s default behaviour is allow opening any file for reading, but forbidding any attempt to write a file. See the example below for an implementation of a less restrictive \code{r_open()}. @@ -173,7 +173,7 @@ restricted environment's \code{sys.modules} dictionary). And their equivalents with access to restricted standard I/O streams: \begin{funcdesc}{s_import}{modulename\optional{\, globals, locals, fromlist}} -Import the module \var{modulename}, raising an \code{ImportError} +Import the module \var{modulename}, raising an \exception{ImportError} exception if the module is considered unsafe. \end{funcdesc} @@ -189,10 +189,11 @@ Unload the module object \var{module}. \subsection{An example} Let us say that we want a slightly more relaxed policy than the -standard RExec class. For example, if we're willing to allow files in -\file{/tmp} to be written, we can subclass the \code{RExec} class: +standard \class{RExec} class. For example, if we're willing to allow +files in \file{/tmp} to be written, we can subclass the \class{RExec} +class: -\bcode\begin{verbatim} +\begin{verbatim} class TmpWriterRExec(rexec.RExec): def r_open(self, file, mode='r', buf=-1): if mode in ('r', 'rb'): @@ -206,7 +207,7 @@ class TmpWriterRExec(rexec.RExec): raise IOError, "'..' in filename forbidden" else: raise IOError, "Illegal open() mode" return open(file, mode, buf) -\end{verbatim}\ecode +\end{verbatim} % Notice that the above code will occasionally forbid a perfectly valid filename; for example, code in the restricted environment won't be diff --git a/Doc/lib/librfc822.tex b/Doc/lib/librfc822.tex index 78bbabd..1374755 100644 --- a/Doc/lib/librfc822.tex +++ b/Doc/lib/librfc822.tex @@ -2,7 +2,7 @@ \label{module-rfc822} \stmodindex{rfc822} -\renewcommand{\indexsubitem}{(in module rfc822)} +\setindexsubitem{(in module rfc822)} This module defines a class, \code{Message}, which represents a collection of ``email headers'' as defined by the Internet standard diff --git a/Doc/lib/librgbimg.tex b/Doc/lib/librgbimg.tex index d923fc2..9432d2e 100644 --- a/Doc/lib/librgbimg.tex +++ b/Doc/lib/librgbimg.tex @@ -9,7 +9,7 @@ is enough in some cases. Currently, colormap files are not supported. The module defines the following variables and functions: -\renewcommand{\indexsubitem}{(in module rgbimg)} +\setindexsubitem{(in module rgbimg)} \begin{excdesc}{error} This exception is raised on all errors, such as unsupported file type, etc. \end{excdesc} diff --git a/Doc/lib/librotor.tex b/Doc/lib/librotor.tex index 4999c81..d2a8460 100644 --- a/Doc/lib/librotor.tex +++ b/Doc/lib/librotor.tex @@ -24,7 +24,7 @@ order. The available functions in this module are: -\renewcommand{\indexsubitem}{(in module rotor)} +\setindexsubitem{(in module rotor)} \begin{funcdesc}{newrotor}{key\optional{\, numrotors}} Return a rotor object. \var{key} is a string containing the encryption key for the object; it can contain arbitrary binary data. The key will be used @@ -35,7 +35,7 @@ if it is omitted, a default value of 6 will be used. Rotor objects have the following methods: -\renewcommand{\indexsubitem}{(rotor method)} +\setindexsubitem{(rotor method)} \begin{funcdesc}{setkey}{key} Sets the rotor's key to \var{key}. \end{funcdesc} @@ -63,7 +63,7 @@ string containing the ciphertext. \end{funcdesc} An example usage: -\bcode\begin{verbatim} +\begin{verbatim} >>> import rotor >>> rt = rotor.newrotor('key', 12) >>> rt.encrypt('bar') @@ -79,7 +79,7 @@ An example usage: >>> rt.decrypt('\357\375$') 'l(\315' >>> del rt -\end{verbatim}\ecode +\end{verbatim} % The module's code is not an exact simulation of the original Enigma device; it implements the rotor encryption scheme differently from the original. The diff --git a/Doc/lib/libselect.tex b/Doc/lib/libselect.tex index 4291dbf..956bf7f 100644 --- a/Doc/lib/libselect.tex +++ b/Doc/lib/libselect.tex @@ -5,7 +5,7 @@ This module provides access to the function \code{select} available in most \UNIX{} versions. It defines the following: -\renewcommand{\indexsubitem}{(in module select)} +\setindexsubitem{(in module select)} \begin{excdesc}{error} The exception raised when an error occurs. The accompanying value is a pair containing the numeric error code from \code{errno} and the diff --git a/Doc/lib/libsgmllib.tex b/Doc/lib/libsgmllib.tex index 5269f20..c63e728 100644 --- a/Doc/lib/libsgmllib.tex +++ b/Doc/lib/libsgmllib.tex @@ -36,7 +36,7 @@ spaces, tabs, and newlines are allowed between the trailing The \code{SGMLParser} class must be instantiated without arguments. It has the following interface methods: -\renewcommand{\indexsubitem}{(SGMLParser method)} +\setindexsubitem{(SGMLParser method)} \begin{funcdesc}{reset}{} Reset the instance. Loses all unprocessed data. This is called diff --git a/Doc/lib/libshelve.tex b/Doc/lib/libshelve.tex index 25ced0e..4349534 100644 --- a/Doc/lib/libshelve.tex +++ b/Doc/lib/libshelve.tex @@ -13,7 +13,7 @@ sub-objects. The keys are ordinary strings. To summarize the interface (\code{key} is a string, \code{data} is an arbitrary object): -\bcode\begin{verbatim} +\begin{verbatim} import shelve d = shelve.open(filename) # open, with (g)dbm filename -- no suffix @@ -28,7 +28,7 @@ flag = d.has_key(key) # true if the key exists list = d.keys() # a list of all existing keys (slow!) d.close() # close it -\end{verbatim}\ecode +\end{verbatim} % Restrictions: diff --git a/Doc/lib/libsignal.tex b/Doc/lib/libsignal.tex index cbec56f..39286a7 100644 --- a/Doc/lib/libsignal.tex +++ b/Doc/lib/libsignal.tex @@ -62,7 +62,7 @@ communication. Use locks instead. The variables defined in the \module{signal} module are: -\renewcommand{\indexsubitem}{(in module signal)} +\setindexsubitem{(in module signal)} \begin{datadesc}{SIG_DFL} This is one of two standard signal handling options; it will simply perform the default function for the signal. For example, on most diff --git a/Doc/lib/libsite.tex b/Doc/lib/libsite.tex index 7e80b08..ba3e23d 100644 --- a/Doc/lib/libsite.tex +++ b/Doc/lib/libsite.tex @@ -6,7 +6,7 @@ In earlier versions of Python (up to and including 1.5a3), scripts or modules that needed to use site-specific modules would place -\code{import site} somewhere near the top of their code. This is no +\samp{import site} somewhere near the top of their code. This is no longer necessary. This will append site-specific paths to to the module search path. @@ -42,29 +42,29 @@ set to \file{/usr/local}. The Python 1.5 library is then installed in files, \file{foo.pth} and \file{bar.pth}. Assume \file{foo.pth} contains the following: -\bcode\begin{verbatim} +\begin{verbatim} # foo package configuration foo bar bletch -\end{verbatim}\ecode +\end{verbatim} and \file{bar.pth} contains: -\bcode\begin{verbatim} +\begin{verbatim} # bar package configuration bar -\end{verbatim}\ecode +\end{verbatim} Then the following directories are added to \code{sys.path}, in this order: -\bcode\begin{verbatim} +\begin{verbatim} /usr/local/python1.5/site-packages/bar /usr/local/python1.5/site-packages/foo -\end{verbatim}\ecode +\end{verbatim} Note that \file{bletch} is omitted because it doesn't exist; the \file{bar} directory precedes the \file{foo} directory because diff --git a/Doc/lib/libsocket.tex b/Doc/lib/libsocket.tex index 41b27f9..9b71f1f 100644 --- a/Doc/lib/libsocket.tex +++ b/Doc/lib/libsocket.tex @@ -47,7 +47,7 @@ method. The module \code{socket} exports the following constants and functions: -\renewcommand{\indexsubitem}{(in module socket)} +\setindexsubitem{(in module socket)} \begin{excdesc}{error} This exception is raised for socket- or address-related errors. The accompanying value is either a string telling what went wrong or a @@ -190,7 +190,7 @@ Socket objects have the following methods. Except for \code{makefile()} these correspond to \UNIX{} system calls applicable to sockets. -\renewcommand{\indexsubitem}{(socket method)} +\setindexsubitem{(socket method)} \begin{funcdesc}{accept}{} Accept a connection. The socket must be bound to an address and listening for connections. @@ -343,7 +343,7 @@ Also note that the server does not \code{send}/\code{receive} on the socket it is listening on but on the new socket returned by \code{accept}. -\bcode\begin{verbatim} +\begin{verbatim} # Echo server program from socket import * HOST = '' # Symbolic name meaning the local host @@ -358,9 +358,9 @@ while 1: if not data: break conn.send(data) conn.close() -\end{verbatim}\ecode +\end{verbatim} % -\bcode\begin{verbatim} +\begin{verbatim} # Echo client program from socket import * HOST = 'daring.cwi.nl' # The remote host @@ -371,7 +371,7 @@ s.send('Hello, world') data = s.recv(1024) s.close() print 'Received', `data` -\end{verbatim}\ecode +\end{verbatim} % \begin{seealso} \seemodule{SocketServer}{classes that simplify writing network servers} diff --git a/Doc/lib/libsocksvr.tex b/Doc/lib/libsocksvr.tex index 98ffec6..c4b0e73 100644 --- a/Doc/lib/libsocksvr.tex +++ b/Doc/lib/libsocksvr.tex @@ -37,7 +37,7 @@ many requests. Server classes have the same external methods and attributes, no matter what network protocol they use: -\renewcommand{\indexsubitem}{(SocketServer protocol)} +\setindexsubitem{(SocketServer protocol)} %XXX should data and methods be intermingled, or separate? % how should the distinction between class and instance variables be diff --git a/Doc/lib/libsoundex.tex b/Doc/lib/libsoundex.tex index 27d9bf3..dc908e7 100644 --- a/Doc/lib/libsoundex.tex +++ b/Doc/lib/libsoundex.tex @@ -2,7 +2,7 @@ \label{module-soundex} \bimodindex{soundex} -\renewcommand{\indexsubitem}{(in module soundex)} +\setindexsubitem{(in module soundex)} The soundex algorithm takes an English word, and returns an easily-computed hash of it; this hash is intended to be the same for words that sound alike. This module provides an interface to the diff --git a/Doc/lib/libstat.tex b/Doc/lib/libstat.tex index 3856723..3030fc6 100644 --- a/Doc/lib/libstat.tex +++ b/Doc/lib/libstat.tex @@ -11,7 +11,7 @@ calls, consult your local man pages. The \code{stat} module defines the following functions: -\renewcommand{\indexsubitem}{(in module stat)} +\setindexsubitem{(in module stat)} \begin{funcdesc}{S_ISDIR}{mode} Return non-zero if the mode was gotten from a directory. @@ -86,7 +86,7 @@ Time of creation. Example: -\bcode\begin{verbatim} +\begin{verbatim} import os, sys from stat import * @@ -108,4 +108,4 @@ def f(file): print 'frobbed', file if __name__ == '__main__': process(sys.argv[1], f) -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libstdwin.tex b/Doc/lib/libstdwin.tex index 39d6d6d..6a0b58d 100644 --- a/Doc/lib/libstdwin.tex +++ b/Doc/lib/libstdwin.tex @@ -36,7 +36,7 @@ of STDWIN for C programmers (aforementioned CWI report). The following functions are defined in the \code{stdwin} module: -\renewcommand{\indexsubitem}{(in module stdwin)} +\setindexsubitem{(in module stdwin)} \begin{funcdesc}{open}{title} Open a new window whose initial title is given by the string argument. Return a window object; window object methods are described below.% @@ -118,14 +118,14 @@ Return the pixel value corresponding to the given color name. Return the default foreground color for unknown color names. Hint: the following code tests whether you are on a machine that supports more than two colors: -\bcode\begin{verbatim} +\begin{verbatim} if stdwin.fetchcolor('black') <> \ stdwin.fetchcolor('red') <> \ stdwin.fetchcolor('white'): print 'color machine' else: print 'monochrome machine' -\end{verbatim}\ecode +\end{verbatim} \end{funcdesc} \begin{funcdesc}{setfgcolor}{pixel} @@ -316,7 +316,7 @@ Window objects are created by \code{stdwin.open()}. They are closed by their \code{close()} method or when they are garbage-collected. Window objects have the following methods: -\renewcommand{\indexsubitem}{(window method)} +\setindexsubitem{(window method)} \begin{funcdesc}{begindrawing}{} Return a drawing object, whose methods (described below) allow drawing @@ -467,7 +467,7 @@ No drawing object may exist when is called. Drawing objects have the following methods: -\renewcommand{\indexsubitem}{(drawing method)} +\setindexsubitem{(drawing method)} \begin{funcdesc}{box}{rect} Draw a box just inside a rectangle. @@ -605,7 +605,7 @@ A menu object represents a menu. The menu is destroyed when the menu object is deleted. The following methods are defined: -\renewcommand{\indexsubitem}{(menu method)} +\setindexsubitem{(menu method)} \begin{funcdesc}{additem}{text\, shortcut} Add a menu item with given text. @@ -643,7 +643,7 @@ Bitmaps are currently not available on the Macintosh. The following methods are defined: -\renewcommand{\indexsubitem}{(bitmap method)} +\setindexsubitem{(bitmap method)} \begin{funcdesc}{getsize}{} Return a tuple representing the width and height of the bitmap. @@ -669,7 +669,7 @@ A text-edit object represents a text-edit block. For semantics, see the STDWIN documentation for C programmers. The following methods exist: -\renewcommand{\indexsubitem}{(text-edit method)} +\setindexsubitem{(text-edit method)} \begin{funcdesc}{arrow}{code} Pass an arrow event to the text-edit block. @@ -756,7 +756,7 @@ left corner of the window. The window will be correctly redrawn when covered and re-exposed. The program quits when the close icon or menu item is requested. -\bcode\begin{verbatim} +\begin{verbatim} import stdwin from stdwinevents import * @@ -773,7 +773,7 @@ def main(): break main() -\end{verbatim}\ecode +\end{verbatim} % \section{Standard Module \sectcode{stdwinevents}} \stmodindex{stdwinevents} @@ -784,10 +784,10 @@ and selection types (\code{WS_PRIMARY} etc.). Read the file for details. Suggested usage is -\bcode\begin{verbatim} +\begin{verbatim} >>> from stdwinevents import * >>> -\end{verbatim}\ecode +\end{verbatim} % \section{Standard Module \sectcode{rect}} \stmodindex{rect} @@ -798,9 +798,9 @@ A rectangle is defined as in module a pair of points, where a point is a pair of integers. For example, the rectangle -\bcode\begin{verbatim} +\begin{verbatim} (10, 20), (90, 80) -\end{verbatim}\ecode +\end{verbatim} % is a rectangle whose left, top, right and bottom edges are 10, 20, 90 and 80, respectively. @@ -809,7 +809,7 @@ Note that the positive vertical axis points down (as in The module defines the following objects: -\renewcommand{\indexsubitem}{(in module rect)} +\setindexsubitem{(in module rect)} \begin{excdesc}{error} The exception raised by functions in this module when they detect an error. @@ -821,7 +821,7 @@ detail. The rectangle returned when some operations return an empty result. This makes it possible to quickly check whether a result is empty: -\bcode\begin{verbatim} +\begin{verbatim} >>> import rect >>> r1 = (10, 20), (90, 80) >>> r2 = (0, 0), (10, 20) @@ -829,7 +829,7 @@ This makes it possible to quickly check whether a result is empty: >>> if r3 is rect.empty: print 'Empty intersection' Empty intersection >>> -\end{verbatim}\ecode +\end{verbatim} \end{datadesc} \begin{funcdesc}{is_empty}{r} diff --git a/Doc/lib/libstring.tex b/Doc/lib/libstring.tex index 1911801..7242c53 100644 --- a/Doc/lib/libstring.tex +++ b/Doc/lib/libstring.tex @@ -10,7 +10,7 @@ classes and some useful string functions. See the module The constants defined in this module are are: -\renewcommand{\indexsubitem}{(data in module string)} +\setindexsubitem{(data in module string)} \begin{datadesc}{digits} The string \code{'0123456789'}. \end{datadesc} @@ -54,7 +54,7 @@ The constants defined in this module are are: The functions defined in this module are: -\renewcommand{\indexsubitem}{(in module string)} +\setindexsubitem{(in module string)} \begin{funcdesc}{atof}{s} Convert a string to a floating point number. The string must have diff --git a/Doc/lib/libstruct.tex b/Doc/lib/libstruct.tex index 19f674c..2ed4f2c 100644 --- a/Doc/lib/libstruct.tex +++ b/Doc/lib/libstruct.tex @@ -13,7 +13,7 @@ See also built-in module \code{array}. The module defines the following exception and functions: -\renewcommand{\indexsubitem}{(in module struct)} +\setindexsubitem{(in module struct)} \begin{excdesc}{error} Exception raised on various occasions; argument is a string describing what is wrong. @@ -120,7 +120,7 @@ byte-swapping); use the appropriate choice of \code{'<'} or Examples (all using native byte order, size and alignment, on a big-endian machine): -\bcode\begin{verbatim} +\begin{verbatim} >>> from struct import * >>> pack('hhl', 1, 2, 3) '\000\001\000\002\000\000\000\003' @@ -129,7 +129,7 @@ big-endian machine): >>> calcsize('hhl') 8 >>> -\end{verbatim}\ecode +\end{verbatim} % Hint: to align the end of a structure to the alignment requirement of a particular type, end the format with the code for that type with a diff --git a/Doc/lib/libsun.tex b/Doc/lib/libsun.tex index a579872..f6d9994 100644 --- a/Doc/lib/libsun.tex +++ b/Doc/lib/libsun.tex @@ -14,7 +14,7 @@ description can be gotten with \samp{man audio}. The module defines the following variables and functions: -\renewcommand{\indexsubitem}{(in module sunaudiodev)} +\setindexsubitem{(in module sunaudiodev)} \begin{excdesc}{error} This exception is raised on all errors. The argument is a string describing what went wrong. @@ -36,7 +36,7 @@ The audio device objects are returned by \code{open} define the following methods (except \code{control} objects which only provide getinfo, setinfo and drain): -\renewcommand{\indexsubitem}{(audio device method)} +\setindexsubitem{(audio device method)} \begin{funcdesc}{close}{} This method explicitly closes the device. It is useful in situations diff --git a/Doc/lib/libsys.tex b/Doc/lib/libsys.tex index e63e616..f7bc8e2 100644 --- a/Doc/lib/libsys.tex +++ b/Doc/lib/libsys.tex @@ -6,7 +6,7 @@ This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available. -\renewcommand{\indexsubitem}{(in module sys)} +\setindexsubitem{(in module sys)} \begin{datadesc}{argv} The list of command line arguments passed to a Python script. @@ -81,10 +81,10 @@ installed; by default, this is also \code{"/usr/local"}. This can be set at build time with the \code{--exec-prefix} argument to the \code{configure} script. Specifically, all configuration files (e.g. the \code{config.h} header file) are installed in the directory -\code{sys.exec_prefix+"/lib/python\emph{VER}/config"}, and shared library +\code{sys.exec_prefix+"/lib/python\var{version}/config"}, and shared library modules are installed in -\code{sys.exec_prefix+"/lib/python\emph{VER}/lib-dynload"}, -where \emph{VER} is equal to \code{sys.version[:3]}. +\code{sys.exec_prefix+"/lib/python\var{version}/lib-dynload"}, +where \var{version} is equal to \code{sys.version[:3]}. \end{datadesc} \begin{funcdesc}{exit}{n} @@ -162,10 +162,10 @@ independent Python files are installed; by default, this is the string \code{"/usr/local"}. This can be set at build time with the \code{--prefix} argument to the \code{configure} script. The main collection of Python library modules is installed in the directory -\code{sys.prefix+"/lib/python\emph{VER}"} while the platform +\code{sys.prefix+"/lib/python\var{version}"} while the platform independent header files (all except \code{config.h}) are stored in -\code{sys.prefix+"/include/python\emph{VER}"}, -where \emph{VER} is equal to \code{sys.version[:3]}. +\code{sys.prefix+"/include/python\var{version}"}, +where \var{version} is equal to \code{sys.version[:3]}. \end{datadesc} diff --git a/Doc/lib/libsyslog.tex b/Doc/lib/libsyslog.tex index 8f4a599..8348e9c 100644 --- a/Doc/lib/libsyslog.tex +++ b/Doc/lib/libsyslog.tex @@ -8,7 +8,7 @@ of the \code{syslog} facility. The module defines the following functions: -\renewcommand{\indexsubitem}{(in module syslog)} +\setindexsubitem{(in module syslog)} \begin{funcdesc}{syslog}{\optional{priority\,} message} Send the string \var{message} to the system logger. diff --git a/Doc/lib/libtempfile.tex b/Doc/lib/libtempfile.tex index f7304ae..d1cd205 100644 --- a/Doc/lib/libtempfile.tex +++ b/Doc/lib/libtempfile.tex @@ -4,7 +4,7 @@ \indexii{temporary}{file name} \indexii{temporary}{file} -\renewcommand{\indexsubitem}{(in module tempfile)} +\setindexsubitem{(in module tempfile)} This module generates temporary file names. It is not \UNIX{} specific, but it may require some help on non-\UNIX{} systems. diff --git a/Doc/lib/libtemplate.tex b/Doc/lib/libtemplate.tex index 29aeb63..4375649 100644 --- a/Doc/lib/libtemplate.tex +++ b/Doc/lib/libtemplate.tex @@ -45,7 +45,7 @@ The \code{spam} module defines the following functions: % Redefine the ``indexsubitem'' macro to point to this module % (alternatively, you can put this at the top of the file): -\renewcommand{\indexsubitem}{(in module spam)} +\setindexsubitem{(in module spam)} % ---- 3.2. ---- % For each function, use a ``funcdesc'' block. This has exactly two @@ -101,12 +101,12 @@ failure. Example: -\bcode\begin{verbatim} +\begin{verbatim} >>> import spam >>> can = spam.open('/etc/passwd') >>> can.empty() >>> can.close() -\end{verbatim}\ecode +\end{verbatim} % % ==== 5. ==== % If your module defines new object types (for a built-in module) or @@ -120,7 +120,7 @@ Example: Spam objects (returned by \code{open()} above) have the following methods. -\renewcommand{\indexsubitem}{(spam method)} +\setindexsubitem{(spam method)} \begin{funcdesc}{empty}{} Empty the can into the trash. diff --git a/Doc/lib/libtermios.tex b/Doc/lib/libtermios.tex index afdd141..e39b905 100644 --- a/Doc/lib/libtermios.tex +++ b/Doc/lib/libtermios.tex @@ -4,7 +4,7 @@ \indexii{\POSIX{}}{I/O control} \indexii{tty}{I/O control} -\renewcommand{\indexsubitem}{(in module termios)} +\setindexsubitem{(in module termios)} This module provides an interface to the \POSIX{} calls for tty I/O control. For a complete description of these calls, see the \POSIX{} or @@ -77,7 +77,7 @@ Note the technique using a separate \code{termios.tcgetattr()} call and a \code{try \ldots{} finally} statement to ensure that the old tty attributes are restored exactly no matter what happens: -\bcode\begin{verbatim} +\begin{verbatim} def getpass(prompt = "Password: "): import termios, TERMIOS, sys fd = sys.stdin.fileno() @@ -90,14 +90,14 @@ def getpass(prompt = "Password: "): finally: termios.tcsetattr(fd, TERMIOS.TCSADRAIN, old) return passwd -\end{verbatim}\ecode +\end{verbatim} % \section{Standard Module \sectcode{TERMIOS}} \stmodindex{TERMIOS} \indexii{\POSIX{}}{I/O control} \indexii{tty}{I/O control} -\renewcommand{\indexsubitem}{(in module TERMIOS)} +\setindexsubitem{(in module TERMIOS)} This module defines the symbolic constants required to use the \code{termios} module (see the previous section). See the \POSIX{} or diff --git a/Doc/lib/libthread.tex b/Doc/lib/libthread.tex index ae11823..24ebac5 100644 --- a/Doc/lib/libthread.tex +++ b/Doc/lib/libthread.tex @@ -20,7 +20,7 @@ IRIX, Solaris 2.x, as well as on systems that have a \POSIX{} thread It defines the following constant and functions: -\renewcommand{\indexsubitem}{(in module thread)} +\setindexsubitem{(in module thread)} \begin{excdesc}{error} Raised on thread-specific errors. \end{excdesc} @@ -64,7 +64,7 @@ another thread is created. Lock objects have the following methods: -\renewcommand{\indexsubitem}{(lock method)} +\setindexsubitem{(lock method)} \begin{funcdesc}{acquire}{\optional{waitflag}} Without the optional argument, this method acquires the lock unconditionally, if necessary waiting until it is released by another diff --git a/Doc/lib/libtime.tex b/Doc/lib/libtime.tex index 74e8104..e05cad2 100644 --- a/Doc/lib/libtime.tex +++ b/Doc/lib/libtime.tex @@ -58,7 +58,7 @@ state to be filled in. The module defines the following functions and data items: -\renewcommand{\indexsubitem}{(in module time)} +\setindexsubitem{(in module time)} \begin{datadesc}{altzone} The offset of the local DST timezone, in seconds west of the 0th diff --git a/Doc/lib/libtraceback.tex b/Doc/lib/libtraceback.tex index 4fcc4d1..2bdd22b 100644 --- a/Doc/lib/libtraceback.tex +++ b/Doc/lib/libtraceback.tex @@ -2,7 +2,7 @@ \label{module-traceback} \stmodindex{traceback} -\renewcommand{\indexsubitem}{(in module traceback)} +\setindexsubitem{(in module traceback)} This module provides a standard interface to format and print stack traces of Python programs. It exactly mimics the behavior of the diff --git a/Doc/lib/libtypes.tex b/Doc/lib/libtypes.tex index 33d1b15..fc1b34e 100644 --- a/Doc/lib/libtypes.tex +++ b/Doc/lib/libtypes.tex @@ -25,7 +25,7 @@ The following values are considered false: \index{false} \begin{itemize} -\renewcommand{\indexsubitem}{(Built-in object)} +\setindexsubitem{(Built-in object)} \item \code{None} \ttindex{None} @@ -409,13 +409,13 @@ If the right argument is a dictionary (or any kind of mapping), then the formats in the string must have a parenthesized key into that dictionary inserted immediately after the \code{\%} character, and each format formats the corresponding entry from the mapping. E.g. -\bcode\begin{verbatim} +\begin{verbatim} >>> count = 2 >>> language = 'Python' >>> print '%(language)s has %(count)03d quote types.' % vars() Python has 002 quote types. >>> -\end{verbatim}\ecode +\end{verbatim} In this case no * specifiers may occur in a format (since they require a sequential parameter list). @@ -466,7 +466,7 @@ The following operations are defined on mutable sequence types (where \indexii{subscript}{assignment} \indexii{slice}{assignment} \stindex{del} -\renewcommand{\indexsubitem}{(list method)} +\setindexsubitem{(list method)} \ttindex{append} \ttindex{count} \ttindex{index} @@ -538,7 +538,7 @@ mapping, \var{k} is a key and \var{x} is an arbitrary object): \indexiii{operations on}{dictionary}{type} \stindex{del} \bifuncindex{len} -\renewcommand{\indexsubitem}{(dictionary method)} +\setindexsubitem{(dictionary method)} \ttindex{keys} \ttindex{has_key} @@ -681,7 +681,7 @@ device or writing a file opened for reading. Files have the following methods: -\renewcommand{\indexsubitem}{(file method)} +\setindexsubitem{(file method)} \begin{funcdesc}{close}{} Close the file. A closed file cannot be read or written anymore. diff --git a/Doc/lib/libtypes2.tex b/Doc/lib/libtypes2.tex index afb02e5..8bf5863 100644 --- a/Doc/lib/libtypes2.tex +++ b/Doc/lib/libtypes2.tex @@ -2,7 +2,7 @@ \label{module-types} \stmodindex{types} -\renewcommand{\indexsubitem}{(in module types)} +\setindexsubitem{(in module types)} This module defines names for all object types that are used by the standard Python interpreter (but not for the types defined by various @@ -14,14 +14,14 @@ all end in \code{Type}. Typical use is for functions that do different things depending on their argument types, like the following: -\bcode\begin{verbatim} +\begin{verbatim} from types import * def delete(list, item): if type(item) is IntType: del list[item] else: list.remove(item) -\end{verbatim}\ecode +\end{verbatim} % The module defines the following names: diff --git a/Doc/lib/liburllib.tex b/Doc/lib/liburllib.tex index 5f8297d..8e7decf 100644 --- a/Doc/lib/liburllib.tex +++ b/Doc/lib/liburllib.tex @@ -5,7 +5,7 @@ \index{World-Wide Web} \index{URL} -\renewcommand{\indexsubitem}{(in module urllib)} +\setindexsubitem{(in module urllib)} This module provides a high-level interface for fetching data across the World-Wide Web. In particular, the \code{urlopen()} function is diff --git a/Doc/lib/liburlparse.tex b/Doc/lib/liburlparse.tex index 651db6d..32d88ee 100644 --- a/Doc/lib/liburlparse.tex +++ b/Doc/lib/liburlparse.tex @@ -7,7 +7,7 @@ \indexii{URL}{parsing} \indexii{relative}{URL} -\renewcommand{\indexsubitem}{(in module urlparse)} +\setindexsubitem{(in module urlparse)} This module defines a standard interface to break URL strings up in components (addessing scheme, network location, path etc.), to combine @@ -35,15 +35,15 @@ retained if present. Example: -\bcode\begin{verbatim} +\begin{verbatim} urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') -\end{verbatim}\ecode +\end{verbatim} % yields the tuple -\bcode\begin{verbatim} +\begin{verbatim} ('http', 'www.cwi.nl:80', '/%7Eguido/Python.html', '', '', '') -\end{verbatim}\ecode +\end{verbatim} % If the \var{default_scheme} argument is specified, it gives the default addressing scheme, to be used only if the URL string does not @@ -70,15 +70,15 @@ components in the relative URL. Example: -\bcode\begin{verbatim} +\begin{verbatim} urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html') -\end{verbatim}\ecode +\end{verbatim} % yields the string -\bcode\begin{verbatim} +\begin{verbatim} 'http://www.cwi.nl/%7Eguido/FAQ.html' -\end{verbatim}\ecode +\end{verbatim} % The \var{allow_fragments} argument has the same meaning as for \code{urlparse()}. diff --git a/Doc/lib/libuser.tex b/Doc/lib/libuser.tex index f0f633c..d5d8d5b 100644 --- a/Doc/lib/libuser.tex +++ b/Doc/lib/libuser.tex @@ -40,13 +40,13 @@ define variables in their \file{.pythonrc.py} file that you test in your module. For example, a module \code{spam} that has a verbosity level can look for a variable \code{user.spam_verbose}, as follows: -\bcode\begin{verbatim} +\begin{verbatim} import user try: verbose = user.spam_verbose # user's verbosity preference except AttributeError: verbose = 0 # default verbosity -\end{verbatim}\ecode +\end{verbatim} Programs with extensive customization needs are better off reading a program-specific customization file. diff --git a/Doc/lib/libuserdict.tex b/Doc/lib/libuserdict.tex index 2084b5c..9b7b2fb 100644 --- a/Doc/lib/libuserdict.tex +++ b/Doc/lib/libuserdict.tex @@ -11,7 +11,7 @@ your own dictionary-like or list-like classes, which can inherit from them and override existing methods or add new ones. In this way one can add new behaviours to dictionaries or lists. -\renewcommand{\indexsubitem}{(in module UserDict)} +\setindexsubitem{(in module UserDict)} The \code{UserDict} module defines the \code{UserDict} class: \begin{funcdesc}{UserDict}{} @@ -20,7 +20,7 @@ contents are kept in a regular dictionary, which is accessible via the \code{data} attribute of \code{UserDict} instances. \end{funcdesc} -\renewcommand{\indexsubitem}{(in module UserList)} +\setindexsubitem{(in module UserList)} The \code{UserList} module defines the \code{UserList} class: \begin{funcdesc}{UserList}{\optional{list}} diff --git a/Doc/lib/libwhichdb.tex b/Doc/lib/libwhichdb.tex index 19bca3a..1805049 100644 --- a/Doc/lib/libwhichdb.tex +++ b/Doc/lib/libwhichdb.tex @@ -6,7 +6,7 @@ The single function in this module attempts to guess which of the several simple database modules available--dbm, gdbm, or dbhash--should be used to open a given file. -\renewcommand{\indexsubitem}{(in module whichdb)} +\setindexsubitem{(in module whichdb)} \begin{funcdesc}{whichdb}{filename} Returns one of the following values: \code{None} if the file can't be opened because it's unreadable or doesn't exist; the empty string diff --git a/Doc/lib/libwhrandom.tex b/Doc/lib/libwhrandom.tex index 09d7816..da3fa8c 100644 --- a/Doc/lib/libwhrandom.tex +++ b/Doc/lib/libwhrandom.tex @@ -5,7 +5,7 @@ This module implements a Wichmann-Hill pseudo-random number generator class that is also named \code{whrandom}. Instances of the \code{whrandom} class have the following methods: -\renewcommand{\indexsubitem}{(in module whrandom)} +\setindexsubitem{(in module whrandom)} \begin{funcdesc}{choice}{seq} Chooses a random element from the non-empty sequence \var{seq} and returns it. @@ -37,10 +37,10 @@ When imported, the \code{whrandom} module also creates an instance of the \code{whrandom} class, and makes the methods of that instance available at the module level. Therefore one can write either \code{N = whrandom.random()} or: -\bcode\begin{verbatim} +\begin{verbatim} generator = whrandom.whrandom() N = generator.random() -\end{verbatim}\ecode +\end{verbatim} % \begin{seealso} \seemodule{random}{generators for various random distributions} diff --git a/Doc/lib/libxdrlib.tex b/Doc/lib/libxdrlib.tex index 3cfa92c..681fc5e 100644 --- a/Doc/lib/libxdrlib.tex +++ b/Doc/lib/libxdrlib.tex @@ -4,7 +4,7 @@ \index{XDR} \index{External Data Representation} -\renewcommand{\indexsubitem}{(in module xdrlib)} +\setindexsubitem{(in module xdrlib)} The \code{xdrlib} module supports the External Data Representation @@ -215,11 +215,11 @@ variables. Here is an example of how you would catch one of these exceptions: -\bcode\begin{verbatim} +\begin{verbatim} import xdrlib p = xdrlib.Packer() try: p.pack_double(8.01) except xdrlib.ConversionError, instance: print 'packing the double failed:', instance.msg -\end{verbatim}\ecode +\end{verbatim} diff --git a/Doc/lib/libxmllib.tex b/Doc/lib/libxmllib.tex index e8ba2e8..d777f08 100644 --- a/Doc/lib/libxmllib.tex +++ b/Doc/lib/libxmllib.tex @@ -10,7 +10,7 @@ for parsing text files formatted in XML (eXtended Markup Language). The \code{XMLParser} class must be instantiated without arguments. It has the following interface methods: -\renewcommand{\indexsubitem}{(XMLParser method)} +\setindexsubitem{(XMLParser method)} \begin{funcdesc}{reset}{} Reset the instance. Loses all unprocessed data. This is called diff --git a/Doc/lib/libzlib.tex b/Doc/lib/libzlib.tex index cca3501..9234c5f 100644 --- a/Doc/lib/libzlib.tex +++ b/Doc/lib/libzlib.tex @@ -13,7 +13,7 @@ later version if one is available. The available functions in this module are: -\renewcommand{\indexsubitem}{(in module zlib)} +\setindexsubitem{(in module zlib)} \begin{funcdesc}{adler32}{string\optional{\, value}} Computes a Adler-32 checksum of \var{string}. (An Adler-32 checksum is almost as reliable as a CRC32 but can be computed much |