More \exception fixes.
This commit is contained in:
parent
da37604ee3
commit
db815abc70
|
@ -40,9 +40,9 @@ modules contained in the package.
|
||||||
|
|
||||||
\begin{funcdesc}{parse}{buf}
|
\begin{funcdesc}{parse}{buf}
|
||||||
Returns an abstract syntax tree for the Python source code in \var{buf}.
|
Returns an abstract syntax tree for the Python source code in \var{buf}.
|
||||||
The function raises SyntaxError if there is an error in the source
|
The function raises \exception{SyntaxError} if there is an error in the
|
||||||
code. The return value is a \class{compiler.ast.Module} instance that
|
source code. The return value is a \class{compiler.ast.Module} instance
|
||||||
contains the tree.
|
that contains the tree.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{parseFile}{path}
|
\begin{funcdesc}{parseFile}{path}
|
||||||
|
|
|
@ -139,8 +139,8 @@ file using the \method{fromfile()} method).
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}[array]{fromunicode}{s}
|
\begin{methoddesc}[array]{fromunicode}{s}
|
||||||
Extends this array with data from the given unicode string.
|
Extends this array with data from the given unicode string. The array
|
||||||
The array must be a type 'u' array; otherwise a ValueError
|
must be a type \code{'u'} array; otherwise a \exception{ValueError}
|
||||||
is raised. Use \samp{array.fromstring(ustr.decode(enc))} to
|
is raised. Use \samp{array.fromstring(ustr.decode(enc))} to
|
||||||
append Unicode data to an array of some other type.
|
append Unicode data to an array of some other type.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
@ -197,8 +197,8 @@ be written to a file by the \method{tofile()} method.)
|
||||||
|
|
||||||
\begin{methoddesc}[array]{tounicode}{}
|
\begin{methoddesc}[array]{tounicode}{}
|
||||||
Convert the array to a unicode string. The array must be
|
Convert the array to a unicode string. The array must be
|
||||||
a type 'u' array; otherwise a ValueError is raised. Use
|
a type \code{'u'} array; otherwise a \exception{ValueError} is raised.
|
||||||
array.tostring().decode(enc) to obtain a unicode string
|
Use \samp{array.tostring().decode(enc)} to obtain a unicode string
|
||||||
from an array of some other type.
|
from an array of some other type.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ not included.
|
||||||
|
|
||||||
The optional argument \var{strict_parsing} is a flag indicating what
|
The optional argument \var{strict_parsing} is a flag indicating what
|
||||||
to do with parsing errors. If false (the default), errors
|
to do with parsing errors. If false (the default), errors
|
||||||
are silently ignored. If true, errors raise a ValueError
|
are silently ignored. If true, errors raise a \exception{ValueError}
|
||||||
exception.
|
exception.
|
||||||
|
|
||||||
Use the \function{\refmodule{urllib}.urlencode()} function to convert
|
Use the \function{\refmodule{urllib}.urlencode()} function to convert
|
||||||
|
@ -347,7 +347,7 @@ not included.
|
||||||
|
|
||||||
The optional argument \var{strict_parsing} is a flag indicating what
|
The optional argument \var{strict_parsing} is a flag indicating what
|
||||||
to do with parsing errors. If false (the default), errors
|
to do with parsing errors. If false (the default), errors
|
||||||
are silently ignored. If true, errors raise a ValueError
|
are silently ignored. If true, errors raise a \exception{ValueError}
|
||||||
exception.
|
exception.
|
||||||
|
|
||||||
Use the \function{\refmodule{urllib}.urlencode()} function to convert
|
Use the \function{\refmodule{urllib}.urlencode()} function to convert
|
||||||
|
|
|
@ -152,7 +152,7 @@ unencodable part of the input and a position where encoding should
|
||||||
continue. The encoder will encode the replacement and continue encoding
|
continue. The encoder will encode the replacement and continue encoding
|
||||||
the original input at the specified position. Negative position values
|
the original input at the specified position. Negative position values
|
||||||
will be treated as being relative to the end of the input string. If the
|
will be treated as being relative to the end of the input string. If the
|
||||||
resulting position is out of bound an IndexError will be raised.
|
resulting position is out of bound an \exception{IndexError} will be raised.
|
||||||
|
|
||||||
Decoding and translating works similar, except \exception{UnicodeDecodeError}
|
Decoding and translating works similar, except \exception{UnicodeDecodeError}
|
||||||
or \exception{UnicodeTranslateError} will be passed to the handler and
|
or \exception{UnicodeTranslateError} will be passed to the handler and
|
||||||
|
@ -696,10 +696,10 @@ transformation can be done (these methods are also called encodings).
|
||||||
The simplest method is to map the codepoints 0-255 to the bytes
|
The simplest method is to map the codepoints 0-255 to the bytes
|
||||||
\code{0x0}-\code{0xff}. This means that a unicode object that contains
|
\code{0x0}-\code{0xff}. This means that a unicode object that contains
|
||||||
codepoints above \code{U+00FF} can't be encoded with this method (which
|
codepoints above \code{U+00FF} can't be encoded with this method (which
|
||||||
is called \code{'latin-1'} or \code{'iso-8859-1'}). unicode.encode() will
|
is called \code{'latin-1'} or \code{'iso-8859-1'}).
|
||||||
raise a UnicodeEncodeError that looks like this: \samp{UnicodeEncodeError:
|
\function{unicode.encode()} will raise a \exception{UnicodeEncodeError}
|
||||||
'latin-1' codec can't encode character u'\e u1234' in position 3: ordinal
|
that looks like this: \samp{UnicodeEncodeError: 'latin-1' codec can't
|
||||||
not in range(256)}.
|
encode character u'\e u1234' in position 3: ordinal not in range(256)}.
|
||||||
|
|
||||||
There's another group of encodings (the so called charmap encodings)
|
There's another group of encodings (the so called charmap encodings)
|
||||||
that choose a different subset of all unicode code points and how
|
that choose a different subset of all unicode code points and how
|
||||||
|
|
|
@ -249,7 +249,7 @@ anyway, unless you ask otherwise by passing a true
|
||||||
ignore_discard=\constant{False}, ignore_expires=\constant{False}}
|
ignore_discard=\constant{False}, ignore_expires=\constant{False}}
|
||||||
Save cookies to a file.
|
Save cookies to a file.
|
||||||
|
|
||||||
This base class raises \class{NotImplementedError}. Subclasses may
|
This base class raises \exception{NotImplementedError}. Subclasses may
|
||||||
leave this method unimplemented.
|
leave this method unimplemented.
|
||||||
|
|
||||||
\var{filename} is the name of file in which to save cookies. If
|
\var{filename} is the name of file in which to save cookies. If
|
||||||
|
|
|
@ -281,7 +281,8 @@ by functions or loops that truncate the stream.
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
\versionchanged[When no iterables are specified, returns a zero length
|
\versionchanged[When no iterables are specified, returns a zero length
|
||||||
iterator instead of raising a TypeError exception]{2.4}
|
iterator instead of raising a \exception{TypeError}
|
||||||
|
exception]{2.4}
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{repeat}{object\optional{, times}}
|
\begin{funcdesc}{repeat}{object\optional{, times}}
|
||||||
|
|
|
@ -68,48 +68,48 @@ flag \var{readermode} is true, then a \samp{mode reader} command is
|
||||||
sent before authentication is performed. Reader mode is sometimes
|
sent before authentication is performed. Reader mode is sometimes
|
||||||
necessary if you are connecting to an NNTP server on the local machine
|
necessary if you are connecting to an NNTP server on the local machine
|
||||||
and intend to call reader-specific commands, such as \samp{group}. If
|
and intend to call reader-specific commands, such as \samp{group}. If
|
||||||
you get unexpected \code{NNTPPermanentError}s, you might need to set
|
you get unexpected \exception{NNTPPermanentError}s, you might need to set
|
||||||
\var{readermode}. \var{readermode} defaults to \code{None}.
|
\var{readermode}. \var{readermode} defaults to \code{None}.
|
||||||
\var{usenetrc} defaults to \code{True}.
|
\var{usenetrc} defaults to \code{True}.
|
||||||
|
|
||||||
\versionchanged[\var{usenetrc} argument added]{2.4}
|
\versionchanged[\var{usenetrc} argument added]{2.4}
|
||||||
\end{classdesc}
|
\end{classdesc}
|
||||||
|
|
||||||
\begin{classdesc}{NNTPError}{}
|
\begin{excdesc}{NNTPError}
|
||||||
Derived from the standard exception \code{Exception}, this is the base
|
Derived from the standard exception \exception{Exception}, this is the
|
||||||
class for all exceptions raised by the \code{nntplib} module.
|
base class for all exceptions raised by the \module{nntplib} module.
|
||||||
\end{classdesc}
|
\end{excdesc}
|
||||||
|
|
||||||
\begin{classdesc}{NNTPReplyError}{}
|
\begin{excdesc}{NNTPReplyError}
|
||||||
Exception raised when an unexpected reply is received from the
|
Exception raised when an unexpected reply is received from the
|
||||||
server. For backwards compatibility, the exception \code{error_reply}
|
server. For backwards compatibility, the exception \code{error_reply}
|
||||||
is equivalent to this class.
|
is equivalent to this class.
|
||||||
\end{classdesc}
|
\end{excdesc}
|
||||||
|
|
||||||
\begin{classdesc}{NNTPTemporaryError}{}
|
\begin{excdesc}{NNTPTemporaryError}
|
||||||
Exception raised when an error code in the range 400--499 is
|
Exception raised when an error code in the range 400--499 is
|
||||||
received. For backwards compatibility, the exception
|
received. For backwards compatibility, the exception
|
||||||
\code{error_temp} is equivalent to this class.
|
\code{error_temp} is equivalent to this class.
|
||||||
\end{classdesc}
|
\end{excdesc}
|
||||||
|
|
||||||
\begin{classdesc}{NNTPPermanentError}{}
|
\begin{excdesc}{NNTPPermanentError}
|
||||||
Exception raised when an error code in the range 500--599 is
|
Exception raised when an error code in the range 500--599 is
|
||||||
received. For backwards compatibility, the exception
|
received. For backwards compatibility, the exception
|
||||||
\code{error_perm} is equivalent to this class.
|
\code{error_perm} is equivalent to this class.
|
||||||
\end{classdesc}
|
\end{excdesc}
|
||||||
|
|
||||||
\begin{classdesc}{NNTPProtocolError}{}
|
\begin{excdesc}{NNTPProtocolError}
|
||||||
Exception raised when a reply is received from the server that does
|
Exception raised when a reply is received from the server that does
|
||||||
not begin with a digit in the range 1--5. For backwards
|
not begin with a digit in the range 1--5. For backwards
|
||||||
compatibility, the exception \code{error_proto} is equivalent to this
|
compatibility, the exception \code{error_proto} is equivalent to this
|
||||||
class.
|
class.
|
||||||
\end{classdesc}
|
\end{excdesc}
|
||||||
|
|
||||||
\begin{classdesc}{NNTPDataError}{}
|
\begin{excdesc}{NNTPDataError}
|
||||||
Exception raised when there is some error in the response data. For
|
Exception raised when there is some error in the response data. For
|
||||||
backwards compatibility, the exception \code{error_data} is
|
backwards compatibility, the exception \code{error_data} is
|
||||||
equivalent to this class.
|
equivalent to this class.
|
||||||
\end{classdesc}
|
\end{excdesc}
|
||||||
|
|
||||||
|
|
||||||
\subsection{NNTP Objects \label{nntp-objects}}
|
\subsection{NNTP Objects \label{nntp-objects}}
|
||||||
|
|
|
@ -100,8 +100,8 @@ options; the traditional \UNIX{} syntax is a hyphen (``-'') followed by a
|
||||||
single letter, e.g. \code{"-x"} or \code{"-F"}. Also, traditional \UNIX{}
|
single letter, e.g. \code{"-x"} or \code{"-F"}. Also, traditional \UNIX{}
|
||||||
syntax allows multiple options to be merged into a single argument,
|
syntax allows multiple options to be merged into a single argument,
|
||||||
e.g. \code{"-x -F"} is equivalent to \code{"-xF"}. The GNU project
|
e.g. \code{"-x -F"} is equivalent to \code{"-xF"}. The GNU project
|
||||||
introduced \code{"-{}-"} followed by a series of hyphen-separated words,
|
introduced \code{"{--}"} followed by a series of hyphen-separated words,
|
||||||
e.g. \code{"-{}-file"} or \code{"-{}-dry-run"}. These are the only two option
|
e.g. \code{"{--}file"} or \code{"{--}dry-run"}. These are the only two option
|
||||||
syntaxes provided by \module{optparse}.
|
syntaxes provided by \module{optparse}.
|
||||||
|
|
||||||
Some other option syntaxes that the world has seen include:
|
Some other option syntaxes that the world has seen include:
|
||||||
|
@ -170,7 +170,7 @@ For example, consider this hypothetical command-line:
|
||||||
prog -v --report /tmp/report.txt foo bar
|
prog -v --report /tmp/report.txt foo bar
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
\code{"-v"} and \code{"-{}-report"} are both options. Assuming that
|
\code{"-v"} and \code{"{--}report"} are both options. Assuming that
|
||||||
\longprogramopt{report} takes one argument, \code{"/tmp/report.txt"} is an option
|
\longprogramopt{report} takes one argument, \code{"/tmp/report.txt"} is an option
|
||||||
argument. \code{"foo"} and \code{"bar"} are positional arguments.
|
argument. \code{"foo"} and \code{"bar"} are positional arguments.
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ programmer errors and user errors. Programmer errors are usually
|
||||||
erroneous calls to \code{parse.add{\_}option()}, e.g. invalid option strings,
|
erroneous calls to \code{parse.add{\_}option()}, e.g. invalid option strings,
|
||||||
unknown option attributes, missing option attributes, etc. These are
|
unknown option attributes, missing option attributes, etc. These are
|
||||||
dealt with in the usual way: raise an exception (either
|
dealt with in the usual way: raise an exception (either
|
||||||
\code{optparse.OptionError} or \code{TypeError}) and let the program crash.
|
\exception{optparse.OptionError} or \exception{TypeError}) and let the program crash.
|
||||||
|
|
||||||
Handling user errors is much more important, since they are guaranteed
|
Handling user errors is much more important, since they are guaranteed
|
||||||
to happen no matter how stable your code is. \module{optparse} can automatically
|
to happen no matter how stable your code is. \module{optparse} can automatically
|
||||||
|
@ -1019,9 +1019,9 @@ callback) as-is.
|
||||||
|
|
||||||
Integer arguments are passed to \code{int()} to convert them to Python
|
Integer arguments are passed to \code{int()} to convert them to Python
|
||||||
integers. If \code{int()} fails, so will \module{optparse}, although with a more
|
integers. If \code{int()} fails, so will \module{optparse}, although with a more
|
||||||
useful error message. (Internally, \module{optparse} raises OptionValueError;
|
useful error message. (Internally, \module{optparse} raises
|
||||||
OptionParser catches this exception higher up and terminates your
|
\exception{OptionValueError}; OptionParser catches this exception higher
|
||||||
program with a useful error message.)
|
up and terminates your program with a useful error message.)
|
||||||
|
|
||||||
Likewise, \code{float} arguments are passed to \code{float()} for conversion,
|
Likewise, \code{float} arguments are passed to \code{float()} for conversion,
|
||||||
\code{long} arguments to \code{long()}, and \code{complex} arguments to
|
\code{long} arguments to \code{long()}, and \code{complex} arguments to
|
||||||
|
@ -1032,7 +1032,7 @@ arguments.
|
||||||
option attribute (a sequence of strings) defines the set of allowed
|
option attribute (a sequence of strings) defines the set of allowed
|
||||||
option arguments. \code{optparse.option.check{\_}choice()} compares
|
option arguments. \code{optparse.option.check{\_}choice()} compares
|
||||||
user-supplied option arguments against this master list and raises
|
user-supplied option arguments against this master list and raises
|
||||||
OptionValueError if an invalid string is given.
|
\exception{OptionValueError} if an invalid string is given.
|
||||||
|
|
||||||
|
|
||||||
\subsubsection{Querying and manipulating your option parser\label{optparse-querying-manipulating-option-parser}}
|
\subsubsection{Querying and manipulating your option parser\label{optparse-querying-manipulating-option-parser}}
|
||||||
|
@ -1052,7 +1052,7 @@ that option is removed. If that option provided any other
|
||||||
option strings, all of those option strings become invalid.
|
option strings, all of those option strings become invalid.
|
||||||
|
|
||||||
If \code{opt{\_}str} does not occur in any option belonging to this
|
If \code{opt{\_}str} does not occur in any option belonging to this
|
||||||
OptionParser, raises ValueError.
|
OptionParser, raises \exception{ValueError}.
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1087,7 +1087,7 @@ The available conflict-handling mechanisms are:
|
||||||
\begin{description}
|
\begin{description}
|
||||||
\item[\code{error} (default)]
|
\item[\code{error} (default)]
|
||||||
assume option conflicts are a programming error and raise
|
assume option conflicts are a programming error and raise
|
||||||
OptionConflictError
|
\exception{OptionConflictError}
|
||||||
\item[\code{resolve}]
|
\item[\code{resolve}]
|
||||||
resolve option conflicts intelligently (see below)
|
resolve option conflicts intelligently (see below)
|
||||||
\end{description}
|
\end{description}
|
||||||
|
@ -1260,7 +1260,7 @@ is a dictionary of arbitrary keyword arguments supplied via
|
||||||
|
|
||||||
\subsubsection{Raising errors in a callback\label{optparse-raising-errors-in-callback}}
|
\subsubsection{Raising errors in a callback\label{optparse-raising-errors-in-callback}}
|
||||||
|
|
||||||
The callback function should raise OptionValueError if there are any
|
The callback function should raise \exception{OptionValueError} if there are any
|
||||||
problems with the option or its argument(s). \module{optparse} catches this and
|
problems with the option or its argument(s). \module{optparse} catches this and
|
||||||
terminates the program, printing the error message you supply to
|
terminates the program, printing the error message you supply to
|
||||||
stderr. Your message should be clear, concise, accurate, and mention
|
stderr. Your message should be clear, concise, accurate, and mention
|
||||||
|
|
|
@ -311,7 +311,7 @@ The mixer object provides two file-like methods:
|
||||||
|
|
||||||
\begin{methoddesc}[mixer device]{close}{}
|
\begin{methoddesc}[mixer device]{close}{}
|
||||||
This method closes the open mixer device file. Any further attempts to
|
This method closes the open mixer device file. Any further attempts to
|
||||||
use the mixer after this file is closed will raise an IOError.
|
use the mixer after this file is closed will raise an \exception{IOError}.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}[mixer device]{fileno}{}
|
\begin{methoddesc}[mixer device]{fileno}{}
|
||||||
|
|
|
@ -30,9 +30,10 @@ Exception raised when an error occurs while attempting to compile the file.
|
||||||
\code{+} \code{'c'} (\code{'o'} if optimization is enabled in the
|
\code{+} \code{'c'} (\code{'o'} if optimization is enabled in the
|
||||||
current interpreter). If \var{dfile} is specified, it is used as
|
current interpreter). If \var{dfile} is specified, it is used as
|
||||||
the name of the source file in error messages instead of \var{file}.
|
the name of the source file in error messages instead of \var{file}.
|
||||||
If \var{doraise} = True, a PyCompileError is raised when an error is
|
If \var{doraise} is true, a \exception{PyCompileError} is raised when
|
||||||
encountered while compiling \var{file}. If \var{doraise} = False (the default),
|
an error is encountered while compiling \var{file}. If \var{doraise}
|
||||||
an error string is written to sys.stderr, but no exception is raised.
|
is false (the default), an error string is written to \code{sys.stderr},
|
||||||
|
but no exception is raised.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{main}{\optional{args}}
|
\begin{funcdesc}{main}{\optional{args}}
|
||||||
|
|
|
@ -931,7 +931,7 @@ The equivalent regular expression would be
|
||||||
\leftline{\strong{Avoiding recursion}}
|
\leftline{\strong{Avoiding recursion}}
|
||||||
|
|
||||||
If you create regular expressions that require the engine to perform a
|
If you create regular expressions that require the engine to perform a
|
||||||
lot of recursion, you may encounter a RuntimeError exception with
|
lot of recursion, you may encounter a \exception{RuntimeError} exception with
|
||||||
the message \code{maximum recursion limit} exceeded. For example,
|
the message \code{maximum recursion limit} exceeded. For example,
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
|
@ -151,12 +151,13 @@ but not found in \class{ImmutableSet}:
|
||||||
\lineiii{\var{s}.add(\var{x})}{}
|
\lineiii{\var{s}.add(\var{x})}{}
|
||||||
{add element \var{x} to set \var{s}}
|
{add element \var{x} to set \var{s}}
|
||||||
\lineiii{\var{s}.remove(\var{x})}{}
|
\lineiii{\var{s}.remove(\var{x})}{}
|
||||||
{remove \var{x} from set \var{s}; raises KeyError if not present}
|
{remove \var{x} from set \var{s}; raises \exception{KeyError}
|
||||||
|
if not present}
|
||||||
\lineiii{\var{s}.discard(\var{x})}{}
|
\lineiii{\var{s}.discard(\var{x})}{}
|
||||||
{removes \var{x} from set \var{s} if present}
|
{removes \var{x} from set \var{s} if present}
|
||||||
\lineiii{\var{s}.pop()}{}
|
\lineiii{\var{s}.pop()}{}
|
||||||
{remove and return an arbitrary element from \var{s}; raises
|
{remove and return an arbitrary element from \var{s}; raises
|
||||||
KeyError if empty}
|
\exception{KeyError} if empty}
|
||||||
\lineiii{\var{s}.clear()}{}
|
\lineiii{\var{s}.clear()}{}
|
||||||
{remove all elements from set \var{s}}
|
{remove all elements from set \var{s}}
|
||||||
\end{tableiii}
|
\end{tableiii}
|
||||||
|
|
|
@ -73,18 +73,18 @@ file type and creator codes will not be correct.
|
||||||
If \var{symlinks} is true, symbolic links in
|
If \var{symlinks} is true, symbolic links in
|
||||||
the source tree are represented as symbolic links in the new tree;
|
the source tree are represented as symbolic links in the new tree;
|
||||||
if false or omitted, the contents of the linked files are copied to
|
if false or omitted, the contents of the linked files are copied to
|
||||||
the new tree. If exception(s) occur, an Error is raised
|
the new tree. If exception(s) occur, an \exception{Error} is raised
|
||||||
with a list of reasons.
|
with a list of reasons.
|
||||||
|
|
||||||
The source code for this should be considered an example rather than
|
The source code for this should be considered an example rather than
|
||||||
a tool.
|
a tool.
|
||||||
|
|
||||||
\versionchanged[Error is raised if any exceptions occur during copying,
|
\versionchanged[\exception{Error} is raised if any exceptions occur during
|
||||||
rather than printing a message]{2.3}
|
copying, rather than printing a message]{2.3}
|
||||||
|
|
||||||
\versionchanged[Create intermediate directories needed to create \var{dst},
|
\versionchanged[Create intermediate directories needed to create \var{dst},
|
||||||
rather than raising an error. Copy permissions and times of directories using
|
rather than raising an error. Copy permissions and times of
|
||||||
\function{copystat()}]{2.5}
|
directories using \function{copystat()}]{2.5}
|
||||||
|
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
|
|
|
@ -1278,7 +1278,8 @@ that do not apply to immutable instances of \class{frozenset}:
|
||||||
\lineiii{\var{s}.add(\var{x})}{}
|
\lineiii{\var{s}.add(\var{x})}{}
|
||||||
{add element \var{x} to set \var{s}}
|
{add element \var{x} to set \var{s}}
|
||||||
\lineiii{\var{s}.remove(\var{x})}{}
|
\lineiii{\var{s}.remove(\var{x})}{}
|
||||||
{remove \var{x} from set \var{s}; raises KeyError if not present}
|
{remove \var{x} from set \var{s}; raises \exception{KeyError}
|
||||||
|
if not present}
|
||||||
\lineiii{\var{s}.discard(\var{x})}{}
|
\lineiii{\var{s}.discard(\var{x})}{}
|
||||||
{removes \var{x} from set \var{s} if present}
|
{removes \var{x} from set \var{s} if present}
|
||||||
\lineiii{\var{s}.pop()}{}
|
\lineiii{\var{s}.pop()}{}
|
||||||
|
@ -1789,14 +1790,14 @@ class, respectively. When a method is unbound, its \code{im_self}
|
||||||
attribute will be \code{None} and if called, an explicit \code{self}
|
attribute will be \code{None} and if called, an explicit \code{self}
|
||||||
object must be passed as the first argument. In this case,
|
object must be passed as the first argument. In this case,
|
||||||
\code{self} must be an instance of the unbound method's class (or a
|
\code{self} must be an instance of the unbound method's class (or a
|
||||||
subclass of that class), otherwise a \code{TypeError} is raised.
|
subclass of that class), otherwise a \exception{TypeError} is raised.
|
||||||
|
|
||||||
Like function objects, methods objects support getting
|
Like function objects, methods objects support getting
|
||||||
arbitrary attributes. However, since method attributes are actually
|
arbitrary attributes. However, since method attributes are actually
|
||||||
stored on the underlying function object (\code{meth.im_func}),
|
stored on the underlying function object (\code{meth.im_func}),
|
||||||
setting method attributes on either bound or unbound methods is
|
setting method attributes on either bound or unbound methods is
|
||||||
disallowed. Attempting to set a method attribute results in a
|
disallowed. Attempting to set a method attribute results in a
|
||||||
\code{TypeError} being raised. In order to set a method attribute,
|
\exception{TypeError} being raised. In order to set a method attribute,
|
||||||
you need to explicitly set it on the underlying function object:
|
you need to explicitly set it on the underlying function object:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
|
@ -135,8 +135,8 @@ The arguments are the same as for the Popen constructor. Example:
|
||||||
|
|
||||||
\begin{funcdesc}{check_call}{*popenargs, **kwargs}
|
\begin{funcdesc}{check_call}{*popenargs, **kwargs}
|
||||||
Run command with arguments. Wait for command to complete. If the exit
|
Run command with arguments. Wait for command to complete. If the exit
|
||||||
code was zero then return, otherwise raise CalledProcessError. The
|
code was zero then return, otherwise raise \exception{CalledProcessError.}
|
||||||
CalledProcessError object will have the return code in the
|
The \exception{CalledProcessError} object will have the return code in the
|
||||||
\member{errno} attribute.
|
\member{errno} attribute.
|
||||||
|
|
||||||
The arguments are the same as for the Popen constructor. Example:
|
The arguments are the same as for the Popen constructor. Example:
|
||||||
|
|
|
@ -384,7 +384,7 @@ determined by sorting the handler instances.
|
||||||
\method{\var{protocol}_open()} are called to handle the request.
|
\method{\var{protocol}_open()} are called to handle the request.
|
||||||
This stage ends when a handler either returns a
|
This stage ends when a handler either returns a
|
||||||
non-\constant{None} value (ie. a response), or raises an exception
|
non-\constant{None} value (ie. a response), or raises an exception
|
||||||
(usually URLError). Exceptions are allowed to propagate.
|
(usually \exception{URLError}). Exceptions are allowed to propagate.
|
||||||
|
|
||||||
In fact, the above algorithm is first tried for methods named
|
In fact, the above algorithm is first tried for methods named
|
||||||
\method{default_open}. If all such methods return
|
\method{default_open}. If all such methods return
|
||||||
|
|
|
@ -69,8 +69,8 @@ The available attributes of this module are:
|
||||||
|
|
||||||
\begin{classdesc}{zipimporter}{archivepath}
|
\begin{classdesc}{zipimporter}{archivepath}
|
||||||
Create a new zipimporter instance. \var{archivepath} must be a path to
|
Create a new zipimporter instance. \var{archivepath} must be a path to
|
||||||
a zipfile. \class{ZipImportError} is raised if \var{archivepath} doesn't
|
a zipfile. \exception{ZipImportError} is raised if \var{archivepath}
|
||||||
point to a valid ZIP archive.
|
doesn't point to a valid ZIP archive.
|
||||||
\end{classdesc}
|
\end{classdesc}
|
||||||
|
|
||||||
\begin{methoddesc}{find_module}{fullname\optional{, path}}
|
\begin{methoddesc}{find_module}{fullname\optional{, path}}
|
||||||
|
@ -83,7 +83,7 @@ The available attributes of this module are:
|
||||||
|
|
||||||
\begin{methoddesc}{get_code}{fullname}
|
\begin{methoddesc}{get_code}{fullname}
|
||||||
Return the code object for the specified module. Raise
|
Return the code object for the specified module. Raise
|
||||||
\class{ZipImportError} if the module couldn't be found.
|
\exception{ZipImportError} if the module couldn't be found.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{get_data}{pathname}
|
\begin{methoddesc}{get_data}{pathname}
|
||||||
|
@ -93,20 +93,20 @@ The available attributes of this module are:
|
||||||
|
|
||||||
\begin{methoddesc}{get_source}{fullname}
|
\begin{methoddesc}{get_source}{fullname}
|
||||||
Return the source code for the specified module. Raise
|
Return the source code for the specified module. Raise
|
||||||
\class{ZipImportError} if the module couldn't be found, return
|
\exception{ZipImportError} if the module couldn't be found, return
|
||||||
\constant{None} if the archive does contain the module, but has
|
\constant{None} if the archive does contain the module, but has
|
||||||
no source for it.
|
no source for it.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{is_package}{fullname}
|
\begin{methoddesc}{is_package}{fullname}
|
||||||
Return True if the module specified by \var{fullname} is a package.
|
Return True if the module specified by \var{fullname} is a package.
|
||||||
Raise \class{ZipImportError} if the module couldn't be found.
|
Raise \exception{ZipImportError} if the module couldn't be found.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{load_module}{fullname}
|
\begin{methoddesc}{load_module}{fullname}
|
||||||
Load the module specified by \var{fullname}. \var{fullname} must be the
|
Load the module specified by \var{fullname}. \var{fullname} must be the
|
||||||
fully qualified (dotted) module name. It returns the imported
|
fully qualified (dotted) module name. It returns the imported
|
||||||
module, or raises \class{ZipImportError} if it wasn't found.
|
module, or raises \exception{ZipImportError} if it wasn't found.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\subsection{Examples}
|
\subsection{Examples}
|
||||||
|
|
|
@ -165,7 +165,7 @@ XML.
|
||||||
|
|
||||||
With an explicit \var{encoding} argument, the result is a byte string
|
With an explicit \var{encoding} argument, the result is a byte string
|
||||||
in the specified encoding. It is recommended that this argument is
|
in the specified encoding. It is recommended that this argument is
|
||||||
always specified. To avoid UnicodeError exceptions in case of
|
always specified. To avoid \exception{UnicodeError} exceptions in case of
|
||||||
unrepresentable text data, the encoding argument should be specified
|
unrepresentable text data, the encoding argument should be specified
|
||||||
as "utf-8".
|
as "utf-8".
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue