Dunder functions in Python


https://docs.python.org/3/reference/datamodel.html

Function Function (rev) Notation
__add__ __radd__ +
__sub__ __rsub__ -
__mul__ __rmul__ *
__matmul__ __rmatmul__ @
__truediv__ __rtruediv__ /
__floordiv__ __rfloordiv__ //
__mod__ __rmod__ %
__divmod__ __rdivmod__ divmod()
__pow__ __rpow__ **
__lshift__ __rlshift__ <<
__rshift__ __rrshift__ >>
__and__ __rand__ &
__xor__ __rxor__ ^
__or__ __ror__

Functions with the r prefix are the same except that the order of arguments is reversed.

Note: Ternary pow() will not try calling rpow().

Function Notation
__iadd__ +=
__isub__ -=
__imul__ *=
__imatmul__ @=
__itruediv__ /=
__ifloordiv__ //=
__imod__ %=
__ipow__ **=
__ilshift__ <<=
__irshift__ >>=
__iand__ &=
__ixor__ ^=
__ior__ │=

(divmod isn't there in this list.)

Function Notation
__neg__ -
__pos__ +
__invert__ ~

__slot__

See: