Your class can define special methods with these names
to tell Python how to handle binary operators such as
*” or “
%”. In each case, the calling sequence
will look something like this:
__method__(self, other): ...
self argument is the left-hand
operand, and the
other argument is the
right-hand operand. Your method will return the result
of the operation.
For each operator, you may supply up to three methods:
The method in the first column performs the normal operation.
The method in the second column is used when the
left-hand operand does not support the given
operation and the operands have different types.
In these methods,
self is the
right-hand operand and
other is the left-hand operand.
The third column implements the “augmented
assignment” operators such as “
+=”. For example, for method
__iadd__(self, other), the method must
perform the equivalent of “