Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Lots of little nits: parameter names in text should be \var{}, etc.
This commit is contained in:
parent
4f496cc5b1
commit
0514ce126a
|
@ -1,11 +1,11 @@
|
|||
% Contributed by Skip Montanaro, from the module's doc strings.
|
||||
|
||||
\section{Built-in Module \sectcode{operator}} % If implemented in C
|
||||
\section{Built-in Module \sectcode{operator}}
|
||||
\bimodindex{operator}
|
||||
|
||||
The \code{operator} module exports a set of functions implemented in C
|
||||
corresponding to the intrinsic operators of Python. For example,
|
||||
{}\code{operator.add(x, y)} is equivalent to the expression x+y. The
|
||||
{}\code{operator.add(x, y)} is equivalent to the expression \code{x+y}. The
|
||||
function names are those used for special class methods; variants without
|
||||
leading and trailing \samp{__} are also provided for convenience.
|
||||
|
||||
|
@ -14,175 +14,179 @@ The \code{operator} module defines the following functions:
|
|||
\renewcommand{\indexsubitem}{(in module operator)}
|
||||
|
||||
\begin{funcdesc}{add}{a, b}
|
||||
Return a + b, for a and b numbers.
|
||||
Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__add__}{a, b}
|
||||
Return a + b, for a and b numbers.
|
||||
Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{sub}{a, b}
|
||||
Return a - b.
|
||||
Return \var{a} \code{-} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__sub__}{a, b}
|
||||
Return a - b.
|
||||
Return \var{a} \code{-} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{mul}{a, b}
|
||||
Return a * b, for a and b numbers.
|
||||
Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__mul__}{a, b}
|
||||
Return a * b, for a and b numbers.
|
||||
Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{div}{a, b}
|
||||
Return a / b.
|
||||
Return \var{a} \code{/} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__div__}{a, b}
|
||||
Return a / b.
|
||||
Return \var{a} \code{/} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{mod}{a, b}
|
||||
Return a \% b.
|
||||
Return \var{a} \code{\%} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__mod__}{a, b}
|
||||
Return a \% b.
|
||||
Return \var{a} \code{\%} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{neg}{o}
|
||||
Return o negated.
|
||||
Return \var{o} negated.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__neg__}{o}
|
||||
Return o negated.
|
||||
Return \var{o} negated.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{pos}{o}
|
||||
Return o positive.
|
||||
Return \var{o} positive.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__pos__}{o}
|
||||
Return o positive.
|
||||
Return \var{o} positive.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{abs}{o}
|
||||
Return the absolute value of o.
|
||||
Return the absolute value of \var{o}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__abs__}{o}
|
||||
Return the absolute value of o.
|
||||
Return the absolute value of \var{o}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{inv}{o}
|
||||
Return the inverse of o.
|
||||
Return the inverse of \var{o}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__inv__}{o}
|
||||
Return the inverse of o.
|
||||
Return the inverse of \var{o}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{lshift}{a, b}
|
||||
Return a shifted left by b.
|
||||
Return \var{a} shifted left by \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__lshift__}{a, b}
|
||||
Return a shifted left by b.
|
||||
Return \var{a} shifted left by \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{rshift}{a, b}
|
||||
Return a shifted right by b.
|
||||
Return \var{a} shifted right by \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__rshift__}{a, b}
|
||||
Return a shifted right by b.
|
||||
Return \var{a} shifted right by \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{and_}{a, b}
|
||||
Return the bitwise and of a and b.
|
||||
Return the bitwise and of \var{a} and \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__and__}{a, b}
|
||||
Return the bitwise and of a and b.
|
||||
Return the bitwise and of \var{a} and \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{or_}{a, b}
|
||||
Return the bitwise or of a and b.
|
||||
Return the bitwise or of \var{a} and \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__or__}{a, b}
|
||||
Return the bitwise or of a and b.
|
||||
Return the bitwise or of \var{a} and \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{concat}{a, b}
|
||||
Return a + b for a and b sequences.
|
||||
Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__concat__}{a, b}
|
||||
Return a + b for a and b sequences.
|
||||
Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{repeat}{a, b}
|
||||
Return a * b where a is a sequence and b is an integer.
|
||||
Return \var{a} \code{*} \var{b} where \var{a} is a sequence and
|
||||
\var{b} is an integer.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__repeat__}{a, b}
|
||||
Return a * b where a is a sequence and b is an integer.
|
||||
Return \var{a} \code{*} \var{b} where \var{a} is a sequence and
|
||||
\var{b} is an integer.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{getitem}{a, b}
|
||||
Return the value of a at index b.
|
||||
Return the value of \var{a} at index \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__getitem__}{a, b}
|
||||
Return the value of a at index b.
|
||||
Return the value of \var{a} at index \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{setitem}{a, b, c}
|
||||
Set the value of a at index b to c.
|
||||
Set the value of \var{a} at index \var{b} to \var{c}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__setitem__}{a, b, c}
|
||||
Set the value of a at index b to c.
|
||||
Set the value of \var{a} at index \var{b} to \var{c}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{delitem}{a, b}
|
||||
Set the value of a at index b.
|
||||
Remove the value of \var{a} at index \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__delitem__}{a, b}
|
||||
Set the value of a at index b.
|
||||
Remove the value of \var{a} at index \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{getslice}{a, b, c}
|
||||
Return the slice of a from index b to index c-1.
|
||||
Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__getslice__}{a, b, c}
|
||||
Return the slice of a from index b to index c-1.
|
||||
Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{setslice}{a, b, c, v}
|
||||
Set the slice of a from index b to index c-1 to the sequence v.
|
||||
Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the
|
||||
sequence \var{v}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__setslice__}{a, b, c, v}
|
||||
Set the slice of a from index b to index c-1 to the sequence v.
|
||||
Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the
|
||||
sequence \var{v}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{delslice}{a, b, c}
|
||||
Delete the slice of a from index b to index c-1.
|
||||
Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__delslice__}{a, b, c}
|
||||
Delete the slice of a from index b to index c-1.
|
||||
Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
|
||||
\end{funcdesc}
|
||||
|
||||
Example: Build a dictionary that maps the ordinals from 0 to 256 to their
|
||||
character equivalents.
|
||||
Example: Build a dictionary that maps the ordinals from \code{0} to
|
||||
\code{256} to their character equivalents.
|
||||
|
||||
\bcode\begin{verbatim}
|
||||
>>> import operator
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
% Contributed by Skip Montanaro, from the module's doc strings.
|
||||
|
||||
\section{Built-in Module \sectcode{operator}} % If implemented in C
|
||||
\section{Built-in Module \sectcode{operator}}
|
||||
\bimodindex{operator}
|
||||
|
||||
The \code{operator} module exports a set of functions implemented in C
|
||||
corresponding to the intrinsic operators of Python. For example,
|
||||
{}\code{operator.add(x, y)} is equivalent to the expression x+y. The
|
||||
{}\code{operator.add(x, y)} is equivalent to the expression \code{x+y}. The
|
||||
function names are those used for special class methods; variants without
|
||||
leading and trailing \samp{__} are also provided for convenience.
|
||||
|
||||
|
@ -14,175 +14,179 @@ The \code{operator} module defines the following functions:
|
|||
\renewcommand{\indexsubitem}{(in module operator)}
|
||||
|
||||
\begin{funcdesc}{add}{a, b}
|
||||
Return a + b, for a and b numbers.
|
||||
Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__add__}{a, b}
|
||||
Return a + b, for a and b numbers.
|
||||
Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{sub}{a, b}
|
||||
Return a - b.
|
||||
Return \var{a} \code{-} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__sub__}{a, b}
|
||||
Return a - b.
|
||||
Return \var{a} \code{-} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{mul}{a, b}
|
||||
Return a * b, for a and b numbers.
|
||||
Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__mul__}{a, b}
|
||||
Return a * b, for a and b numbers.
|
||||
Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{div}{a, b}
|
||||
Return a / b.
|
||||
Return \var{a} \code{/} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__div__}{a, b}
|
||||
Return a / b.
|
||||
Return \var{a} \code{/} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{mod}{a, b}
|
||||
Return a \% b.
|
||||
Return \var{a} \code{\%} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__mod__}{a, b}
|
||||
Return a \% b.
|
||||
Return \var{a} \code{\%} \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{neg}{o}
|
||||
Return o negated.
|
||||
Return \var{o} negated.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__neg__}{o}
|
||||
Return o negated.
|
||||
Return \var{o} negated.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{pos}{o}
|
||||
Return o positive.
|
||||
Return \var{o} positive.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__pos__}{o}
|
||||
Return o positive.
|
||||
Return \var{o} positive.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{abs}{o}
|
||||
Return the absolute value of o.
|
||||
Return the absolute value of \var{o}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__abs__}{o}
|
||||
Return the absolute value of o.
|
||||
Return the absolute value of \var{o}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{inv}{o}
|
||||
Return the inverse of o.
|
||||
Return the inverse of \var{o}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__inv__}{o}
|
||||
Return the inverse of o.
|
||||
Return the inverse of \var{o}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{lshift}{a, b}
|
||||
Return a shifted left by b.
|
||||
Return \var{a} shifted left by \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__lshift__}{a, b}
|
||||
Return a shifted left by b.
|
||||
Return \var{a} shifted left by \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{rshift}{a, b}
|
||||
Return a shifted right by b.
|
||||
Return \var{a} shifted right by \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__rshift__}{a, b}
|
||||
Return a shifted right by b.
|
||||
Return \var{a} shifted right by \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{and_}{a, b}
|
||||
Return the bitwise and of a and b.
|
||||
Return the bitwise and of \var{a} and \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__and__}{a, b}
|
||||
Return the bitwise and of a and b.
|
||||
Return the bitwise and of \var{a} and \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{or_}{a, b}
|
||||
Return the bitwise or of a and b.
|
||||
Return the bitwise or of \var{a} and \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__or__}{a, b}
|
||||
Return the bitwise or of a and b.
|
||||
Return the bitwise or of \var{a} and \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{concat}{a, b}
|
||||
Return a + b for a and b sequences.
|
||||
Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__concat__}{a, b}
|
||||
Return a + b for a and b sequences.
|
||||
Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{repeat}{a, b}
|
||||
Return a * b where a is a sequence and b is an integer.
|
||||
Return \var{a} \code{*} \var{b} where \var{a} is a sequence and
|
||||
\var{b} is an integer.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__repeat__}{a, b}
|
||||
Return a * b where a is a sequence and b is an integer.
|
||||
Return \var{a} \code{*} \var{b} where \var{a} is a sequence and
|
||||
\var{b} is an integer.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{getitem}{a, b}
|
||||
Return the value of a at index b.
|
||||
Return the value of \var{a} at index \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__getitem__}{a, b}
|
||||
Return the value of a at index b.
|
||||
Return the value of \var{a} at index \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{setitem}{a, b, c}
|
||||
Set the value of a at index b to c.
|
||||
Set the value of \var{a} at index \var{b} to \var{c}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__setitem__}{a, b, c}
|
||||
Set the value of a at index b to c.
|
||||
Set the value of \var{a} at index \var{b} to \var{c}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{delitem}{a, b}
|
||||
Set the value of a at index b.
|
||||
Remove the value of \var{a} at index \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__delitem__}{a, b}
|
||||
Set the value of a at index b.
|
||||
Remove the value of \var{a} at index \var{b}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{getslice}{a, b, c}
|
||||
Return the slice of a from index b to index c-1.
|
||||
Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__getslice__}{a, b, c}
|
||||
Return the slice of a from index b to index c-1.
|
||||
Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{setslice}{a, b, c, v}
|
||||
Set the slice of a from index b to index c-1 to the sequence v.
|
||||
Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the
|
||||
sequence \var{v}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__setslice__}{a, b, c, v}
|
||||
Set the slice of a from index b to index c-1 to the sequence v.
|
||||
Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the
|
||||
sequence \var{v}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{delslice}{a, b, c}
|
||||
Delete the slice of a from index b to index c-1.
|
||||
Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{__delslice__}{a, b, c}
|
||||
Delete the slice of a from index b to index c-1.
|
||||
Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
|
||||
\end{funcdesc}
|
||||
|
||||
Example: Build a dictionary that maps the ordinals from 0 to 256 to their
|
||||
character equivalents.
|
||||
Example: Build a dictionary that maps the ordinals from \code{0} to
|
||||
\code{256} to their character equivalents.
|
||||
|
||||
\bcode\begin{verbatim}
|
||||
>>> import operator
|
||||
|
|
Loading…
Reference in New Issue