Binary Operators
Operator Method
+ obj.__add__(self, other)
- obj.__sub__(self, other)
* obj.__mul__(self, other)
// obj.__floordiv__(self, other)
/ obj.__div__(self, other)
% obj.__mod__(self, other)
** obj.__pow__(self, other[, modulo])
<< obj.__lshift__(self, other)
>> obj.__rshift__(self, other)
& obj.__and__(self, other)
^ obj.__xor__(self, other)
| obj.__or__(self, other)
Assignment Operators:
Operator Method
+= obj.__iadd__(self, other)
-= obj.__isub__(self, other)
*= obj.__imul__(self, other)
/= obj.__idiv__(self, other)
//= obj.__ifloordiv__(self, other)
%= obj.__imod__(self, other)
**= obj.__ipow__(self, other[, modulo])
<<= obj.__ilshift__(self, other)
>>= obj.__irshift__(self, other)
&= obj.__iand__(self, other)
^= obj.__ixor__(self, other)
|= obj.__ior__(self, other)
Unary Operators:
Operator Method
- obj.__neg__(self)
+ obj.__pos__(self)
abs() obj.__abs__(self)
~ obj.__invert__(self)
complex() obj.__complex__(self)
int() obj.__int__(self)
long() obj.__long__(self)
float() obj.__float__(self)
oct() obj.__oct__(self)
hex() obj.__hex__(self)
Comparison Operators
Operator Method
< obj.__lt__(self, other)
<= obj.__le__(self, other)
== obj.__eq__(self, other)
!= obj.__ne__(self, other)
>= obj.__ge__(self, other)
> obj.__gt__(self, other)
Tags: magicmethod