Commit 816cbabd authored by Fred Drake's avatar Fred Drake

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.
parent b959b832
......@@ -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}
......
......@@ -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}
......@@ -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}
......
......@@ -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.
......
......@@ -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}
......@@ -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}
......@@ -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
......
......@@ -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:
......
\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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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:
......
......@@ -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
......
......@@ -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
......
\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__}
......@@ -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.
......
......@@ -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
......
......@@ -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.
......
......@@ -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}
\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.
......
......@@ -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
......
......@@ -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
......
......@@ -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}
......
......@@ -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})}.
......
......@@ -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}
......
......@@ -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
......
......@@ -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
......
......@@ -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}}
......
......@@ -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}{}
......
......@@ -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}
......
......@@ -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}
......
\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}
......@@ -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
......
......@@ -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}
......
......@@ -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
......
......@@ -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
......
......@@ -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}
......@@ -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
......
......@@ -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}
......
......@@ -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}
......@@ -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
......
......@@ -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
......
......@@ -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}
......@@ -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.
......
\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}
......@@ -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
......
......@@ -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.
......
......@@ -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
......
......@@ -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
......
\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
......
......@@ -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.
......
......@@ -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}.
......@@ -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
......
......@@ -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}
......@@ -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
......
......@@ -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}
......
......@@ -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}
......
......@@ -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)]
......
......@@ -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()}
......
......@@ -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}
......
......@@ -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}
......@@ -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
......
......@@ -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
......
This diff is collapsed.
......@@ -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}
......
......@@ -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
......
......@@ -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
......
......@@ -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}.
......
......@@ -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}.
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
\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
......
......@@ -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
......
......@@ -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}
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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:
......
......@@ -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
......
......@@ -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
......
......@@ -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}
......
......@@ -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
......
......@@ -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
......
......@@ -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}
......@@ -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}
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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}
......
......@@ -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.
......
......@@ -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.
......
......@@ -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.
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment