
66
|
Python Pocket Reference
Augmented binary methods
__iadd__(self, other)
__isub__(self, other)
__imul__(self, other)
__idiv__(self, other)
__ifloordiv__(self, other)
__itruediv__(self, other)
__imod__(self, other)
__ipow__(self, other[, modulo])
__ilshift__(self, other)
__irshift__(self, other)
__iand__(self, other)
__ixor__(self, other)
__ior__(self, other)
These are augmented assignment (in-place) methods.
Respectively, they are called for the following assign-
ment statement formats:
+=, -=, *=, /=, //=, /=, %=, **=,
<<=, >>=, &=, ^=, and |=. These methods should attempt to
do the operation in-place (modifying
self) and return the
result (which can be
self). If a method is not defined,
then the augmented operation falls back on the normal
methods. To evaluate
X+=Y, where X is an instance of a
class that has an
__iadd__, x.__iadd__(y) is called. Oth-
erwise,
__add__ and __radd__ are considered.
For Numbers (Other Operations)
__neg__(self)
Invoked on -self.
__pos__(self)
Invoked on +self.
__abs__(self)
Invoked on abs(self).
__invert__(self)
Invoked on ~self.