\end{funcdesc}
\begin{funcdesc}{fromlist}{list}
-Appends items from the list. This is equivalent to
-\code{for x in \var{list}: a.append(x)}
+Append items from the list. This is equivalent to
+\code{for x in \var{list}:\ a.append(x)}
except that if there is a type error, the array is unchanged.
\end{funcdesc}
the form was submitted through a POST request). The keys in the
resulting dictionary are the field names used in the submission; the
values are {\em lists} of the field values (since field name may be
-used multiple times in a single form). As a side effect, it sets
+used multiple times in a single form). \samp{\%} escapes in the
+values are translated to their single-character equivalent using
+\code{urllib.unquote()}. As a side effect, this function sets
\code{environ['QUERY_STRING']} to the raw query string, if it isn't
already set.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}{print_form}{form}
-Print a piece of HTML text showing the contents of the \var{form}.
+Print a piece of HTML text showing the contents of the \var{form} (a
+dictionary, an instance of the \code{FormContentDict} class defined
+below, or a subclass thereof).
This is mainly useful when debugging a CGI script.
\end{funcdesc}
\begin{funcdesc}{compile}{string\, filename\, kind}
Compile the \var{string} into a code object. Code objects can be
- executed by a \code{exec()} statement or evaluated by a call to
+ executed by an \code{exec} statement or evaluated by a call to
\code{eval()}. The \var{filename} argument should
give the file from which the code was read; pass e.g. \code{'<string>'}
if it wasn't read from a file. The \var{kind} argument specifies
object and a string. The string must be the name
of one of the object's attributes. The function deletes
the named attribute, provided the object allows it. For example,
- \code{setattr(\var{x}, '\var{foobar}')} is equivalent to
+ \code{delattr(\var{x}, '\var{foobar}')} is equivalent to
\code{del \var{x}.\var{foobar}}.
\end{funcdesc}
\end{verbatim}\ecode
This function can also be used to execute arbitrary code objects
- (e.g. created by \code{compile()}). In this case pass a code
+ (e.g.\ created by \code{compile()}). In this case pass a code
object instead of a string. The code object must have been compiled
passing \code{'eval'} to the \var{kind} argument.
- Note: dynamic execution of statements is supported by the
+ Hints: dynamic execution of statements is supported by the
\code{exec} statement. Execution of statements from a file is
- supported by the \code{execfile()} function.
+ supported by the \code{execfile()} function. The \code{vars()}
+ function returns the current local dictionary, which may be useful
+ to pass around for use by \code{eval()} or \code{execfile()}.
\end{funcdesc}
\var{function} returns true. If \var{list} is a string or a tuple,
the result also has that type; otherwise it is always a list. If
\var{function} is \code{None}, the identity function is assumed,
-i.e. all elements of \var{list} that are false (zero or empty) are
+i.e.\ all elements of \var{list} that are false (zero or empty) are
removed.
\end{funcdesc}
\begin{funcdesc}{pow}{x\, y\optional{\, z}}
Return \var{x} to the power \var{y}; if \var{z} is present, return
\var{x} to the power \var{y}, modulo \var{z} (computed more
- efficiently that \code{pow(\var{x}, \var{y}) \% \var{z}}).
+ efficiently than \code{pow(\var{x}, \var{y}) \% \var{z}}).
The arguments must have
numeric types. With mixed operand types, the rules for binary
arithmetic operators apply. The effective operand type is also the
\begin{funcdesc}{str}{object}
Return a string containing a nicely printable representation of an
object. For strings, this returns the string itself. The difference
-with \code{repr(\var{object}} is that \code{str(\var{object}} does not
+with \code{repr(\var{object})} is that \code{str(\var{object})} does not
always attempt to return a string that is acceptable to \code{eval()};
its goal is to return a printable string.
\end{funcdesc}
corresponding symbol table are undefined.%
\footnote{In the current implementation, local variable bindings
cannot normally be affected this way, but variables retrieved from
-other scopes can be. This may change.}
+other scopes (e.g. modules) can be. This may change.}
\end{funcdesc}
\begin{funcdesc}{xrange}{\optional{start\,} end\optional{\, step}}
This module defines a class which implements the client side of the
HTTP protocol. It is normally not used directly --- the module
-\code{urlllib} module uses it to handle URLs that use HTTP.
+\code{urllib} uses it to handle URLs that use HTTP.
\stmodindex{urllib}
The module defines one class, \code{HTTP}. An \code{HTTP} instance
Complete the request by shutting down the sending end of the socket,
read the reply from the server, and return a triple (\var{replycode},
\var{message}, \var{headers}). Here \var{replycode} is the integer
-reply code from the request (e.g. \code{200} if the request was
+reply code from the request (e.g.\ \code{200} if the request was
handled properly); \var{message} is the message string corresponding
to the reply code; and \var{header} is an instance of the class
\code{rfc822.Message} containing the headers received from the server.
\bimodindex{imp}
\index{import}
-This module provides an interface to the mechanisms use to implement
+This module provides an interface to the mechanisms used to implement
the \code{import} statement. It defines the following constants and
functions:
command (but not ``\code{he}'' or ``\code{hel}'', nor ``\code{H}'' or
``\code{Help} or ``\code{HELP}''). Arguments to commands must be
separated by whitespace (spaces or tabs). Optional arguments are
-enclosed in square brackets (``\code{[]}'')in the command syntax; the
+enclosed in square brackets (``\code{[]}'') in the command syntax; the
square brackets must not be typed. Alternatives in the command syntax
are separated by a vertical bar (``\code{|}'').
Written by James Roskind%
\footnote{
-Updated and converted to LaTeX by Guido van Rossum. The references to
+Updated and converted to \LaTeX\ by Guido van Rossum. The references to
the old profiler are left in the text, although it no longer exists.
}
they are followed by an unrecognized escape character.
\emph{However}, if you want to include a literal \dfn{backslash} in a
regular expression represented as a string literal, you have to
-\emph{quadruple} it. E.g. to extract LaTeX \samp{\e section\{{\rm
+\emph{quadruple} it. E.g.\ to extract \LaTeX\ \samp{\e section\{{\rm
\ldots}\}} headers from a document, you can use this pattern:
\code{'\e \e \e\e section\{\e (.*\e )\}'}.
\begin{funcdesc}{symcomp}{pattern\optional{\, translate}}
This is like \code{compile}, but supports symbolic group names: if a
-parentheses-enclosed group begins with a group name in angular
+parenthesis-enclosed group begins with a group name in angular
brackets, e.g. \code{'\e(<id>[a-z][a-z0-9]*\e)'}, the group can
be referenced by its name in arguments to the \code{group} method of
the resulting compiled regular expression object, like this:
\end{funcdesc}
\begin{funcdesc}{getallmatchingheaders}{name}
-Return a list of lines consisting of all headers whose header matches
+Return a list of lines consisting of all headers matching
\var{name}, if any. Each physical line, whether it is a continuation
line or not, is a separate list item. Return the empty list if no
header matches \var{name}.
\var{name} exists, return \code{None, None}; otherwise both the full
name and the address are (possibly empty )strings.
-Example: if \code{m}'s first \code{From} header contains the string
+Example: If \code{m}'s first \code{From} header contains the string
\code{'guido@cwi.nl (Guido van Rossum)'}, then
\code{m.getaddr('From')} will yield the pair
-\code{('Guido van Rossum', 'guido\@cwi.nl')}.
+\code{('Guido van Rossum', 'guido@cwi.nl')}.
If the header contained
-\code{'Guido van Rossum <guido\@cwi.nl>'} instead, it would yield the
+\code{'Guido van Rossum <guido@cwi.nl>'} instead, it would yield the
exact same result.
\end{funcdesc}
\begin{funcdesc}{getdate}{name}
Retrieve a header using \code{getheader} and parse it into a 9-tuple
-compatible with \code{time.kmtime()}. If there is no header matching
+compatible with \code{time.mktime()}. If there is no header matching
\var{name}, or it is unparsable, return \code{None}.
Date parsing appears to be a black art, and not all mailers adhere to
This module defines a class \code{SGMLParser} which serves as the
basis for parsing text files formatted in SGML (Standard Generalized
Mark-up Language). In fact, it does not provide a full SGML parser
---- it only parses SGML insofar as it is used by HTML, and module only
+--- it only parses SGML insofar as it is used by HTML, and the module only
exists as a basis for the \code{htmllib} module.
\stmodindex{htmllib}
``\code{\&\var{ref};}'' where \var{ref} is an alphabetic entity
reference. It looks for \var{ref} in the instance (or class)
variable \code{entitydefs} which should give the entity's translation.
-If a translation is found, it callse the method \code{handle_data()}
-with the translation; otherwise, it callse the method
+If a translation is found, it calls the method \code{handle_data()}
+with the translation; otherwise, it calls the method
\code{unknown_entityref(\var{ref})}.
\end{funcdesc}
Note that the parser maintains a stack of opening tags for which no
matching closing tag has been found yet. Only tags processed by
-\code{start_\var{tag}()} are pushed on this stack. Definition if a
+\code{start_\var{tag}()} are pushed on this stack. Definition of a
\code{end_\var{tag}()} method is optional for these tags. For tags
processed by \code{do_\var{tag}()} or by \code{unknown_tag()}, no
\code{end_\var{tag}()} method must be defined.
\lineiii{d}{double}{float}
\end{tableiii}
-A format character may be preceded by an integral repeat count; e.g.
+A format character may be preceded by an integral repeat count; e.g.\
the format string \code{'4h'} means exactly the same as \code{'hhhh'}.
C numbers are represented in the machine's native format and byte
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
-repeat count of zero, e.g. the format \code{'llh0l'} specifies two
+repeat count of zero, e.g.\ the format \code{'llh0l'} specifies two
pad bytes at the end, assuming longs are aligned on 4-byte boundaries.
-(More format characters are planned, e.g. \code{'s'} for character
+(More format characters are planned, e.g.\ \code{'s'} for character
arrays, upper case for unsigned variants, and a way to specify the
byte order, which is useful for [de]constructing network packets and
reading/writing portable binary file formats like TIFF and AIFF.)
as thread switches and signal handlers. The default is 10, meaning
the check is performed every 10 Python virtual instructions. Setting
it to a larger value may increase performance for programs using
-threads. Setting it to a value <= 0 checks every virtual instruction,
+threads. Setting it to a value $\leq 0$ checks every virtual instruction,
maximizing responsiveness as well as overhead.
\end{funcdesc}
\item
The precision of the various real-time functions may be less than
suggested by the units in which their value or argument is expressed.
-E.g. on most UNIX systems, the clock ``ticks'' only every 1/50th or
+E.g.\ on most UNIX systems, the clock ``ticks'' only every 1/50th or
1/100th of a second, and on the Mac, it ticks 60 times a second.
\end{itemize}
\begin{funcdesc}{gmtime}{secs}
Convert a time expressed in seconds since the epoch to a tuple of 9
-integers, in UTC: year (e.g. 1993), month (1-12), day (1-31), hour
-(0-23), minute (0-59), second (0-59), weekday (0-6, monday is 0),
-julian day (1-366), dst flag (always zero). Fractions of a second are
+integers, in UTC: year (e.g.\ 1993), month (1--12), day (1--31), hour
+(0--23), minute (0--59), second (0--59), weekday (0--6, monday is 0),
+Julian day (1--366), dst flag (always zero). Fractions of a second are
ignored. Note subtle differences with the C function of this name.
\end{funcdesc}
\begin{funcdesc}{urlretrieve}{url}
Copy a network object denoted by a URL to a local file, if necessary.
-If the URL points to a local file, or a valid cached copy of the the
+If the URL points to a local file, or a valid cached copy of the
object exists, the object is not copied. Return a tuple (\var{filename},
\var{headers}) where \var{filename} is the local file name under which
the object can be found, and \var{headers} is either \code{None} (for
\end{funcdesc}
\begin{funcdesc}{unquote}{string}
-Remove \code{\%xx} escapes by their single-character equivalent.
+Replace \samp{\%xx} escapes by their single-character equivalent.
Example: \code{unquote('/\%7Econnolly/')} yields \code{'/\~connolly/'}.
\end{funcdesc}
find the time to hack proper processing of Expiration time headers.
\item
-There should be an function to query whether a particular URL is in
+There should be a function to query whether a particular URL is in
the cache.
\item
\end{funcdesc}
\begin{funcdesc}{fromlist}{list}
-Appends items from the list. This is equivalent to
-\code{for x in \var{list}: a.append(x)}
+Append items from the list. This is equivalent to
+\code{for x in \var{list}:\ a.append(x)}
except that if there is a type error, the array is unchanged.
\end{funcdesc}
the form was submitted through a POST request). The keys in the
resulting dictionary are the field names used in the submission; the
values are {\em lists} of the field values (since field name may be
-used multiple times in a single form). As a side effect, it sets
+used multiple times in a single form). \samp{\%} escapes in the
+values are translated to their single-character equivalent using
+\code{urllib.unquote()}. As a side effect, this function sets
\code{environ['QUERY_STRING']} to the raw query string, if it isn't
already set.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}{print_form}{form}
-Print a piece of HTML text showing the contents of the \var{form}.
+Print a piece of HTML text showing the contents of the \var{form} (a
+dictionary, an instance of the \code{FormContentDict} class defined
+below, or a subclass thereof).
This is mainly useful when debugging a CGI script.
\end{funcdesc}
\begin{funcdesc}{compile}{string\, filename\, kind}
Compile the \var{string} into a code object. Code objects can be
- executed by a \code{exec()} statement or evaluated by a call to
+ executed by an \code{exec} statement or evaluated by a call to
\code{eval()}. The \var{filename} argument should
give the file from which the code was read; pass e.g. \code{'<string>'}
if it wasn't read from a file. The \var{kind} argument specifies
object and a string. The string must be the name
of one of the object's attributes. The function deletes
the named attribute, provided the object allows it. For example,
- \code{setattr(\var{x}, '\var{foobar}')} is equivalent to
+ \code{delattr(\var{x}, '\var{foobar}')} is equivalent to
\code{del \var{x}.\var{foobar}}.
\end{funcdesc}
\end{verbatim}\ecode
This function can also be used to execute arbitrary code objects
- (e.g. created by \code{compile()}). In this case pass a code
+ (e.g.\ created by \code{compile()}). In this case pass a code
object instead of a string. The code object must have been compiled
passing \code{'eval'} to the \var{kind} argument.
- Note: dynamic execution of statements is supported by the
+ Hints: dynamic execution of statements is supported by the
\code{exec} statement. Execution of statements from a file is
- supported by the \code{execfile()} function.
+ supported by the \code{execfile()} function. The \code{vars()}
+ function returns the current local dictionary, which may be useful
+ to pass around for use by \code{eval()} or \code{execfile()}.
\end{funcdesc}
\var{function} returns true. If \var{list} is a string or a tuple,
the result also has that type; otherwise it is always a list. If
\var{function} is \code{None}, the identity function is assumed,
-i.e. all elements of \var{list} that are false (zero or empty) are
+i.e.\ all elements of \var{list} that are false (zero or empty) are
removed.
\end{funcdesc}
\begin{funcdesc}{pow}{x\, y\optional{\, z}}
Return \var{x} to the power \var{y}; if \var{z} is present, return
\var{x} to the power \var{y}, modulo \var{z} (computed more
- efficiently that \code{pow(\var{x}, \var{y}) \% \var{z}}).
+ efficiently than \code{pow(\var{x}, \var{y}) \% \var{z}}).
The arguments must have
numeric types. With mixed operand types, the rules for binary
arithmetic operators apply. The effective operand type is also the
\begin{funcdesc}{str}{object}
Return a string containing a nicely printable representation of an
object. For strings, this returns the string itself. The difference
-with \code{repr(\var{object}} is that \code{str(\var{object}} does not
+with \code{repr(\var{object})} is that \code{str(\var{object})} does not
always attempt to return a string that is acceptable to \code{eval()};
its goal is to return a printable string.
\end{funcdesc}
corresponding symbol table are undefined.%
\footnote{In the current implementation, local variable bindings
cannot normally be affected this way, but variables retrieved from
-other scopes can be. This may change.}
+other scopes (e.g. modules) can be. This may change.}
\end{funcdesc}
\begin{funcdesc}{xrange}{\optional{start\,} end\optional{\, step}}
This module defines a class which implements the client side of the
HTTP protocol. It is normally not used directly --- the module
-\code{urlllib} module uses it to handle URLs that use HTTP.
+\code{urllib} uses it to handle URLs that use HTTP.
\stmodindex{urllib}
The module defines one class, \code{HTTP}. An \code{HTTP} instance
Complete the request by shutting down the sending end of the socket,
read the reply from the server, and return a triple (\var{replycode},
\var{message}, \var{headers}). Here \var{replycode} is the integer
-reply code from the request (e.g. \code{200} if the request was
+reply code from the request (e.g.\ \code{200} if the request was
handled properly); \var{message} is the message string corresponding
to the reply code; and \var{header} is an instance of the class
\code{rfc822.Message} containing the headers received from the server.
\bimodindex{imp}
\index{import}
-This module provides an interface to the mechanisms use to implement
+This module provides an interface to the mechanisms used to implement
the \code{import} statement. It defines the following constants and
functions:
command (but not ``\code{he}'' or ``\code{hel}'', nor ``\code{H}'' or
``\code{Help} or ``\code{HELP}''). Arguments to commands must be
separated by whitespace (spaces or tabs). Optional arguments are
-enclosed in square brackets (``\code{[]}'')in the command syntax; the
+enclosed in square brackets (``\code{[]}'') in the command syntax; the
square brackets must not be typed. Alternatives in the command syntax
are separated by a vertical bar (``\code{|}'').
Written by James Roskind%
\footnote{
-Updated and converted to LaTeX by Guido van Rossum. The references to
+Updated and converted to \LaTeX\ by Guido van Rossum. The references to
the old profiler are left in the text, although it no longer exists.
}
they are followed by an unrecognized escape character.
\emph{However}, if you want to include a literal \dfn{backslash} in a
regular expression represented as a string literal, you have to
-\emph{quadruple} it. E.g. to extract LaTeX \samp{\e section\{{\rm
+\emph{quadruple} it. E.g.\ to extract \LaTeX\ \samp{\e section\{{\rm
\ldots}\}} headers from a document, you can use this pattern:
\code{'\e \e \e\e section\{\e (.*\e )\}'}.
\begin{funcdesc}{symcomp}{pattern\optional{\, translate}}
This is like \code{compile}, but supports symbolic group names: if a
-parentheses-enclosed group begins with a group name in angular
+parenthesis-enclosed group begins with a group name in angular
brackets, e.g. \code{'\e(<id>[a-z][a-z0-9]*\e)'}, the group can
be referenced by its name in arguments to the \code{group} method of
the resulting compiled regular expression object, like this:
\end{funcdesc}
\begin{funcdesc}{getallmatchingheaders}{name}
-Return a list of lines consisting of all headers whose header matches
+Return a list of lines consisting of all headers matching
\var{name}, if any. Each physical line, whether it is a continuation
line or not, is a separate list item. Return the empty list if no
header matches \var{name}.
\var{name} exists, return \code{None, None}; otherwise both the full
name and the address are (possibly empty )strings.
-Example: if \code{m}'s first \code{From} header contains the string
+Example: If \code{m}'s first \code{From} header contains the string
\code{'guido@cwi.nl (Guido van Rossum)'}, then
\code{m.getaddr('From')} will yield the pair
-\code{('Guido van Rossum', 'guido\@cwi.nl')}.
+\code{('Guido van Rossum', 'guido@cwi.nl')}.
If the header contained
-\code{'Guido van Rossum <guido\@cwi.nl>'} instead, it would yield the
+\code{'Guido van Rossum <guido@cwi.nl>'} instead, it would yield the
exact same result.
\end{funcdesc}
\begin{funcdesc}{getdate}{name}
Retrieve a header using \code{getheader} and parse it into a 9-tuple
-compatible with \code{time.kmtime()}. If there is no header matching
+compatible with \code{time.mktime()}. If there is no header matching
\var{name}, or it is unparsable, return \code{None}.
Date parsing appears to be a black art, and not all mailers adhere to
This module defines a class \code{SGMLParser} which serves as the
basis for parsing text files formatted in SGML (Standard Generalized
Mark-up Language). In fact, it does not provide a full SGML parser
---- it only parses SGML insofar as it is used by HTML, and module only
+--- it only parses SGML insofar as it is used by HTML, and the module only
exists as a basis for the \code{htmllib} module.
\stmodindex{htmllib}
``\code{\&\var{ref};}'' where \var{ref} is an alphabetic entity
reference. It looks for \var{ref} in the instance (or class)
variable \code{entitydefs} which should give the entity's translation.
-If a translation is found, it callse the method \code{handle_data()}
-with the translation; otherwise, it callse the method
+If a translation is found, it calls the method \code{handle_data()}
+with the translation; otherwise, it calls the method
\code{unknown_entityref(\var{ref})}.
\end{funcdesc}
Note that the parser maintains a stack of opening tags for which no
matching closing tag has been found yet. Only tags processed by
-\code{start_\var{tag}()} are pushed on this stack. Definition if a
+\code{start_\var{tag}()} are pushed on this stack. Definition of a
\code{end_\var{tag}()} method is optional for these tags. For tags
processed by \code{do_\var{tag}()} or by \code{unknown_tag()}, no
\code{end_\var{tag}()} method must be defined.
\lineiii{d}{double}{float}
\end{tableiii}
-A format character may be preceded by an integral repeat count; e.g.
+A format character may be preceded by an integral repeat count; e.g.\
the format string \code{'4h'} means exactly the same as \code{'hhhh'}.
C numbers are represented in the machine's native format and byte
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
-repeat count of zero, e.g. the format \code{'llh0l'} specifies two
+repeat count of zero, e.g.\ the format \code{'llh0l'} specifies two
pad bytes at the end, assuming longs are aligned on 4-byte boundaries.
-(More format characters are planned, e.g. \code{'s'} for character
+(More format characters are planned, e.g.\ \code{'s'} for character
arrays, upper case for unsigned variants, and a way to specify the
byte order, which is useful for [de]constructing network packets and
reading/writing portable binary file formats like TIFF and AIFF.)
as thread switches and signal handlers. The default is 10, meaning
the check is performed every 10 Python virtual instructions. Setting
it to a larger value may increase performance for programs using
-threads. Setting it to a value <= 0 checks every virtual instruction,
+threads. Setting it to a value $\leq 0$ checks every virtual instruction,
maximizing responsiveness as well as overhead.
\end{funcdesc}
\item
The precision of the various real-time functions may be less than
suggested by the units in which their value or argument is expressed.
-E.g. on most UNIX systems, the clock ``ticks'' only every 1/50th or
+E.g.\ on most UNIX systems, the clock ``ticks'' only every 1/50th or
1/100th of a second, and on the Mac, it ticks 60 times a second.
\end{itemize}
\begin{funcdesc}{gmtime}{secs}
Convert a time expressed in seconds since the epoch to a tuple of 9
-integers, in UTC: year (e.g. 1993), month (1-12), day (1-31), hour
-(0-23), minute (0-59), second (0-59), weekday (0-6, monday is 0),
-julian day (1-366), dst flag (always zero). Fractions of a second are
+integers, in UTC: year (e.g.\ 1993), month (1--12), day (1--31), hour
+(0--23), minute (0--59), second (0--59), weekday (0--6, monday is 0),
+Julian day (1--366), dst flag (always zero). Fractions of a second are
ignored. Note subtle differences with the C function of this name.
\end{funcdesc}
\begin{funcdesc}{urlretrieve}{url}
Copy a network object denoted by a URL to a local file, if necessary.
-If the URL points to a local file, or a valid cached copy of the the
+If the URL points to a local file, or a valid cached copy of the
object exists, the object is not copied. Return a tuple (\var{filename},
\var{headers}) where \var{filename} is the local file name under which
the object can be found, and \var{headers} is either \code{None} (for
\end{funcdesc}
\begin{funcdesc}{unquote}{string}
-Remove \code{\%xx} escapes by their single-character equivalent.
+Replace \samp{\%xx} escapes by their single-character equivalent.
Example: \code{unquote('/\%7Econnolly/')} yields \code{'/\~connolly/'}.
\end{funcdesc}
find the time to hack proper processing of Expiration time headers.
\item
-There should be an function to query whether a particular URL is in
+There should be a function to query whether a particular URL is in
the cache.
\item