Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc90cc2

Browse files
committed
Additional docs for __iadd__ and family, closing SF bug #117178 and SF patch
#102169.
1 parent 2a22200 commit dc90cc2

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Doc/ref/ref3.tex

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,32 @@ \subsection{Emulating numeric types\label{numeric-types}}
12931293
complicated).
12941294
\end{methoddesc}
12951295

1296+
\begin{methoddesc}[numeric object]{__iadd__}{self, other}
1297+
\methodline[numeric object]{__isub__}{self, other}
1298+
\methodline[numeric object]{__imul__}{self, other}
1299+
\methodline[numeric object]{__idiv__}{self, other}
1300+
\methodline[numeric object]{__imod__}{self, other}
1301+
\methodline[numeric object]{__ipow__}{self, other\optional{, modulo}}
1302+
\methodline[numeric object]{__ilshift__}{self, other}
1303+
\methodline[numeric object]{__irshift__}{self, other}
1304+
\methodline[numeric object]{__iand__}{self, other}
1305+
\methodline[numeric object]{__ixor__}{self, other}
1306+
\methodline[numeric object]{__ior__}{self, other}
1307+
These methods are called to implement the augmented arithmetic operations
1308+
(\code{+=}, \code{-=}, \code{*=}, \code{/=}, \code{\%=}, \code{**=},
1309+
\code{<<=}, \code{>>=}, \code{\&=}, \code{\^=}, \code{|=}). These methods
1310+
should attempt to do the operation in-place (modifying \var{self}) and
1311+
return the result (which could be, but does not have to be, \var{self}). If
1312+
a specific method is not defined, the augmented operation falls back to the
1313+
normal methods. For instance, to evaluate the expression
1314+
\var{x}\code{+=}\var{y}, where \var{x} is an instance of a class that has an
1315+
\method{__iadd__()} method, \code{\var{x}.__iadd__(\var{y})} is called. If
1316+
\var{x} is an instance of a class that does not define a \method{__iadd()}
1317+
method, \code{\var{x}.__add__(\var{y})} and \code{\var{y}.__radd__(\var{x})}
1318+
are considered, as with the evaluation of \var{x}\code{+}\var{y}.
1319+
1320+
\end{methoddesc}
1321+
12961322
\begin{methoddesc}[numeric object]{__neg__}{self}
12971323
\methodline[numeric object]{__pos__}{self}
12981324
\methodline[numeric object]{__abs__}{self}

0 commit comments

Comments
 (0)