Some logical markup.

Combine function pairs:  add() and __add__() go together.  This way they
share a single description and use less space.
This commit is contained in:
Fred Drake 1998-03-08 05:56:15 +00:00
parent 0fd72ee369
commit c07ae9f4d2
2 changed files with 46 additions and 178 deletions

View File

@ -4,187 +4,121 @@
\label{module-operator} \label{module-operator}
\bimodindex{operator} \bimodindex{operator}
The \code{operator} module exports a set of functions implemented in C The \module{operator} module exports a set of functions implemented in C
corresponding to the intrinsic operators of Python. For example, corresponding to the intrinsic operators of Python. For example,
\code{operator.add(x, y)} is equivalent to the expression \code{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 function names are those used for special class methods; variants without
leading and trailing \samp{__} are also provided for convenience. leading and trailing \samp{__} are also provided for convenience.
The \code{operator} module defines the following functions: The \module{operator} module defines the following functions:
\setindexsubitem{(in module operator)}
\begin{funcdesc}{add}{a, b} \begin{funcdesc}{add}{a, b}
Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers. \funcline{__add__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__add__}{a, b}
Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers. Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{sub}{a, b} \begin{funcdesc}{sub}{a, b}
Return \var{a} \code{-} \var{b}. \funcline{__sub__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__sub__}{a, b}
Return \var{a} \code{-} \var{b}. Return \var{a} \code{-} \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{mul}{a, b} \begin{funcdesc}{mul}{a, b}
Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers. \funcline{__mul__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__mul__}{a, b}
Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers. Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{div}{a, b} \begin{funcdesc}{div}{a, b}
Return \var{a} \code{/} \var{b}. \funcline{__div__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__div__}{a, b}
Return \var{a} \code{/} \var{b}. Return \var{a} \code{/} \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{mod}{a, b} \begin{funcdesc}{mod}{a, b}
Return \var{a} \code{\%} \var{b}. \funcline{__mod__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__mod__}{a, b}
Return \var{a} \code{\%} \var{b}. Return \var{a} \code{\%} \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{neg}{o} \begin{funcdesc}{neg}{o}
Return \var{o} negated. \funcline{__neg__}{o}
\end{funcdesc}
\begin{funcdesc}{__neg__}{o}
Return \var{o} negated. Return \var{o} negated.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{pos}{o} \begin{funcdesc}{pos}{o}
Return \var{o} positive. \funcline{__pos__}{o}
\end{funcdesc}
\begin{funcdesc}{__pos__}{o}
Return \var{o} positive. Return \var{o} positive.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{abs}{o} \begin{funcdesc}{abs}{o}
Return the absolute value of \var{o}. \funcline{__abs__}{o}
\end{funcdesc}
\begin{funcdesc}{__abs__}{o}
Return the absolute value of \var{o}. Return the absolute value of \var{o}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{inv}{o} \begin{funcdesc}{inv}{o}
Return the inverse of \var{o}. \funcline{__inv__}{o}
\end{funcdesc}
\begin{funcdesc}{__inv__}{o}
Return the inverse of \var{o}. Return the inverse of \var{o}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{lshift}{a, b} \begin{funcdesc}{lshift}{a, b}
Return \var{a} shifted left by \var{b}. \funcline{__lshift__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__lshift__}{a, b}
Return \var{a} shifted left by \var{b}. Return \var{a} shifted left by \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{rshift}{a, b} \begin{funcdesc}{rshift}{a, b}
Return \var{a} shifted right by \var{b}. \funcline{__rshift__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__rshift__}{a, b}
Return \var{a} shifted right by \var{b}. Return \var{a} shifted right by \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{and_}{a, b} \begin{funcdesc}{and_}{a, b}
Return the bitwise and of \var{a} and \var{b}. \funcline{__and__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__and__}{a, b}
Return the bitwise and of \var{a} and \var{b}. Return the bitwise and of \var{a} and \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{or_}{a, b} \begin{funcdesc}{or_}{a, b}
Return the bitwise or of \var{a} and \var{b}. \funcline{__or__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__or__}{a, b}
Return the bitwise or of \var{a} and \var{b}. Return the bitwise or of \var{a} and \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{concat}{a, b} \begin{funcdesc}{concat}{a, b}
Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences. \funcline{__concat__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__concat__}{a, b}
Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences. Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{repeat}{a, b} \begin{funcdesc}{repeat}{a, b}
Return \var{a} \code{*} \var{b} where \var{a} is a sequence and \funcline{__repeat__}{a, b}
\var{b} is an integer.
\end{funcdesc}
\begin{funcdesc}{__repeat__}{a, b}
Return \var{a} \code{*} \var{b} where \var{a} is a sequence and Return \var{a} \code{*} \var{b} where \var{a} is a sequence and
\var{b} is an integer. \var{b} is an integer.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{getitem}{a, b} \begin{funcdesc}{getitem}{a, b}
Return the value of \var{a} at index \var{b}. \funcline{__getitem__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__getitem__}{a, b}
Return the value of \var{a} at index \var{b}. Return the value of \var{a} at index \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setitem}{a, b, c} \begin{funcdesc}{setitem}{a, b, c}
Set the value of \var{a} at index \var{b} to \var{c}. \funcline{__setitem__}{a, b, c}
\end{funcdesc}
\begin{funcdesc}{__setitem__}{a, b, c}
Set the value of \var{a} at index \var{b} to \var{c}. Set the value of \var{a} at index \var{b} to \var{c}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{delitem}{a, b} \begin{funcdesc}{delitem}{a, b}
Remove the value of \var{a} at index \var{b}. \funcline{__delitem__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__delitem__}{a, b}
Remove the value of \var{a} at index \var{b}. Remove the value of \var{a} at index \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{getslice}{a, b, c} \begin{funcdesc}{getslice}{a, b, c}
Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}. \funcline{__getslice__}{a, b, c}
\end{funcdesc}
\begin{funcdesc}{__getslice__}{a, b, c}
Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}. Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setslice}{a, b, c, v} \begin{funcdesc}{setslice}{a, b, c, v}
Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the \funcline{__setslice__}{a, b, c, v}
sequence \var{v}.
\end{funcdesc}
\begin{funcdesc}{__setslice__}{a, b, c, v}
Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the
sequence \var{v}. sequence \var{v}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{delslice}{a, b, c} \begin{funcdesc}{delslice}{a, b, c}
\funcline{__delslice__}{a, b, c}
Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}. Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{__delslice__}{a, b, c}
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 \code{0} to Example: Build a dictionary that maps the ordinals from \code{0} to
\code{256} to their character equivalents. \code{256} to their character equivalents.

View File

@ -4,187 +4,121 @@
\label{module-operator} \label{module-operator}
\bimodindex{operator} \bimodindex{operator}
The \code{operator} module exports a set of functions implemented in C The \module{operator} module exports a set of functions implemented in C
corresponding to the intrinsic operators of Python. For example, corresponding to the intrinsic operators of Python. For example,
\code{operator.add(x, y)} is equivalent to the expression \code{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 function names are those used for special class methods; variants without
leading and trailing \samp{__} are also provided for convenience. leading and trailing \samp{__} are also provided for convenience.
The \code{operator} module defines the following functions: The \module{operator} module defines the following functions:
\setindexsubitem{(in module operator)}
\begin{funcdesc}{add}{a, b} \begin{funcdesc}{add}{a, b}
Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers. \funcline{__add__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__add__}{a, b}
Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers. Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{sub}{a, b} \begin{funcdesc}{sub}{a, b}
Return \var{a} \code{-} \var{b}. \funcline{__sub__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__sub__}{a, b}
Return \var{a} \code{-} \var{b}. Return \var{a} \code{-} \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{mul}{a, b} \begin{funcdesc}{mul}{a, b}
Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers. \funcline{__mul__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__mul__}{a, b}
Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers. Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{div}{a, b} \begin{funcdesc}{div}{a, b}
Return \var{a} \code{/} \var{b}. \funcline{__div__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__div__}{a, b}
Return \var{a} \code{/} \var{b}. Return \var{a} \code{/} \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{mod}{a, b} \begin{funcdesc}{mod}{a, b}
Return \var{a} \code{\%} \var{b}. \funcline{__mod__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__mod__}{a, b}
Return \var{a} \code{\%} \var{b}. Return \var{a} \code{\%} \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{neg}{o} \begin{funcdesc}{neg}{o}
Return \var{o} negated. \funcline{__neg__}{o}
\end{funcdesc}
\begin{funcdesc}{__neg__}{o}
Return \var{o} negated. Return \var{o} negated.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{pos}{o} \begin{funcdesc}{pos}{o}
Return \var{o} positive. \funcline{__pos__}{o}
\end{funcdesc}
\begin{funcdesc}{__pos__}{o}
Return \var{o} positive. Return \var{o} positive.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{abs}{o} \begin{funcdesc}{abs}{o}
Return the absolute value of \var{o}. \funcline{__abs__}{o}
\end{funcdesc}
\begin{funcdesc}{__abs__}{o}
Return the absolute value of \var{o}. Return the absolute value of \var{o}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{inv}{o} \begin{funcdesc}{inv}{o}
Return the inverse of \var{o}. \funcline{__inv__}{o}
\end{funcdesc}
\begin{funcdesc}{__inv__}{o}
Return the inverse of \var{o}. Return the inverse of \var{o}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{lshift}{a, b} \begin{funcdesc}{lshift}{a, b}
Return \var{a} shifted left by \var{b}. \funcline{__lshift__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__lshift__}{a, b}
Return \var{a} shifted left by \var{b}. Return \var{a} shifted left by \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{rshift}{a, b} \begin{funcdesc}{rshift}{a, b}
Return \var{a} shifted right by \var{b}. \funcline{__rshift__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__rshift__}{a, b}
Return \var{a} shifted right by \var{b}. Return \var{a} shifted right by \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{and_}{a, b} \begin{funcdesc}{and_}{a, b}
Return the bitwise and of \var{a} and \var{b}. \funcline{__and__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__and__}{a, b}
Return the bitwise and of \var{a} and \var{b}. Return the bitwise and of \var{a} and \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{or_}{a, b} \begin{funcdesc}{or_}{a, b}
Return the bitwise or of \var{a} and \var{b}. \funcline{__or__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__or__}{a, b}
Return the bitwise or of \var{a} and \var{b}. Return the bitwise or of \var{a} and \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{concat}{a, b} \begin{funcdesc}{concat}{a, b}
Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences. \funcline{__concat__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__concat__}{a, b}
Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences. Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{repeat}{a, b} \begin{funcdesc}{repeat}{a, b}
Return \var{a} \code{*} \var{b} where \var{a} is a sequence and \funcline{__repeat__}{a, b}
\var{b} is an integer.
\end{funcdesc}
\begin{funcdesc}{__repeat__}{a, b}
Return \var{a} \code{*} \var{b} where \var{a} is a sequence and Return \var{a} \code{*} \var{b} where \var{a} is a sequence and
\var{b} is an integer. \var{b} is an integer.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{getitem}{a, b} \begin{funcdesc}{getitem}{a, b}
Return the value of \var{a} at index \var{b}. \funcline{__getitem__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__getitem__}{a, b}
Return the value of \var{a} at index \var{b}. Return the value of \var{a} at index \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setitem}{a, b, c} \begin{funcdesc}{setitem}{a, b, c}
Set the value of \var{a} at index \var{b} to \var{c}. \funcline{__setitem__}{a, b, c}
\end{funcdesc}
\begin{funcdesc}{__setitem__}{a, b, c}
Set the value of \var{a} at index \var{b} to \var{c}. Set the value of \var{a} at index \var{b} to \var{c}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{delitem}{a, b} \begin{funcdesc}{delitem}{a, b}
Remove the value of \var{a} at index \var{b}. \funcline{__delitem__}{a, b}
\end{funcdesc}
\begin{funcdesc}{__delitem__}{a, b}
Remove the value of \var{a} at index \var{b}. Remove the value of \var{a} at index \var{b}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{getslice}{a, b, c} \begin{funcdesc}{getslice}{a, b, c}
Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}. \funcline{__getslice__}{a, b, c}
\end{funcdesc}
\begin{funcdesc}{__getslice__}{a, b, c}
Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}. Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setslice}{a, b, c, v} \begin{funcdesc}{setslice}{a, b, c, v}
Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the \funcline{__setslice__}{a, b, c, v}
sequence \var{v}.
\end{funcdesc}
\begin{funcdesc}{__setslice__}{a, b, c, v}
Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the
sequence \var{v}. sequence \var{v}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{delslice}{a, b, c} \begin{funcdesc}{delslice}{a, b, c}
\funcline{__delslice__}{a, b, c}
Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}. Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{__delslice__}{a, b, c}
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 \code{0} to Example: Build a dictionary that maps the ordinals from \code{0} to
\code{256} to their character equivalents. \code{256} to their character equivalents.