Python __rrshift__() Magic Method

Syntax object.__rrshift__(self, other) The Python __rrshift__() method implements the reverse bitwise right-shift operation with reflected, swapped operands. So, when you call x >> y, Python attempts to call x.__rshift__(y). If the method is not implemented, Python attempts to call y.__rrshift__(x) on the right operand and if this isn’t implemented either, it raises a TypeError. The … Read more

Python __rlshift__() Magic Method

Syntax object.__rlshift__(self, other) The Python __rlshift__() method implements the reverse bitwise left-shift operation with reflected, swapped operands. So, when you call x << y, Python attempts to call x.__lshift__(y). If the method is not implemented, Python attempts to call y.__rlshift__(x) on the right operand and if this isn’t implemented either, it raises a TypeError. The … Read more

Python __rpow__() Magic Method

Syntax object.__rpow__(self, other) The Python __rpow__() method implements the reverse exponentiation operation that is exponentiation with reflected, swapped operands. So, when you call x ** y, Python attempts to call x.__pow__(y). Only if the method is not implemented on the left operand, Python attempts to call __rpow__ on the right operand and if this isn’t … Read more

Python __rdivmod__() Magic Method

Syntax object.__rdivmod__(self, other) The Python __rdivmod__() method implements the divmod() built-in function with reflected, swapped operands. So, when you call divmod(x, y), Python attempts to call x.__divmod__(y). If the method is not implemented, Python attempts to call __rdivmod__ on the right operand. Only if this isn’t implemented either, it raises a TypeError. We call this … Read more

Python __rmod__() Magic Method

Syntax object.__rmod__(self, other) The Python __rmod__() method implements the reverse modulo operation with reflected, swapped operands. So, when you call x % y, Python attempts to call x.__mod__(y). If the method is not implemented, Python attempts to call __rmod__ on the right operand and if this isn’t implemented either, it raises a TypeError. We call … Read more

Python __rfloordiv__() Magic Method

Syntax object.__rfloordiv__(self, other) The Python __rfloordiv__() method implements the reverse floor (integer) division operation with reflected, swapped operands. So, when you call x // y, Python attempts to call x.__floordiv__(y). If the method is not implemented, Python attempts to call __rfloordiv__ on the right operand and if this isn’t implemented either, it raises a TypeError. … Read more

Python __rtruediv__() Magic Method

Syntax object.__rtruediv__(self, other) The Python __rtruediv__() method implements the reverse true division operation with reflected, swapped operands. So, when you call x / y, Python attempts to call x.__truediv__(y). If the method is not implemented, Python attempts to call __rtruediv__ on the right operand and if this isn’t implemented either, it raises a TypeError. We … Read more

Python __ror__() Magic Method

Syntax object.__ror__(self, other) The Python __ror__() method implements the reverse Bitwise OR | operation with reflected, swapped operands. So, when you call x | y, Python attempts to call x.__or__(y). If the method is not implemented, Python attempts to call __ror__ on the right operand and if this isn’t implemented either, it raises a TypeError. … Read more

Python __rmatmul__() Magic Method

Syntax object.__rmatmul__(self, other) The Python __rmatmul__() method implements the reverse matrix multiplication @ operation with reflected, swapped operands. So, when you call x @ y, Python attempts to call x.__matmul__(y). If the method is not implemented, Python attempts to call __rmatmul__ on the right operand and if this isn’t implemented either, it raises a TypeError. … Read more

Python __rand__() Magic Method

Syntax object.__rand__(self, other) The Python __rand__() method implements the reverse Bitwise AND * operation with reflected, swapped operands. So, when you call x * y, Python attempts to call x.__and__(y). If the method is not implemented, Python attempts to call __rand__ on the right operand and if this isn’t implemented either, it raises a TypeError. … Read more

Python __rmul__() Magic Method

Syntax object.__rmul__(self, other) The Python __rmul__() method implements the reverse multiplication operation that is multiplication with reflected, swapped operands. So, when you call x * y, Python attempts to call x.__mul__(y). Only if the method is not implemented on the left operand, Python attempts to call __rmul__ on the right operand and if this isn’t … Read more

Python __rsub__() Magic Method

Syntax object.__rsub__(self, other) The Python __rsub__() method implements the reverse subtraction operation that is subtraction with reflected, swapped operands. So, when you call x – y, Python attempts to call x.__sub__(y). Only if the method is not implemented on the left operand, Python attempts to call __rsub__ on the right operand and if this isn’t … Read more