Python __eq__ Magic Method

To customize the behavior of the equality operator x == y, override the __eq__() dunder method in your class definition. Python internally calls x.__eq__(y) to compare two objects using x == y. If the __eq__() method is not defined, Python will use the is operator per default that checks for two arbitrary objects whether they … Read more

Python __ixor__() Magic Method

Syntax object.__ixor__(self, other) The Python __ixor__() magic method implements the in-place bitwise XOR x ^= y that calculates the result of the bitwise XOR operation x ^ y, and assigns it to the first operands’ variable x. This type of in-place operation is also called augmented arithmetic assignment. The method simply returns the new value … Read more

Python __ior__() Magic Method

Syntax object.__ior__(self, other) The Python __ior__() magic method implements the in-place bitwise OR x |= y that calculates the result of the bitwise OR operation x | y, and assigns it to the first operands’ variable x. This type of in-place operation is also called augmented arithmetic assignment. The method simply returns the new value … Read more

Python __iand__() Magic Method

Syntax object.__iand__(self, other) The Python __iand__() magic method implements the in-place bitwise AND x &= y that calculates the result of the bitwise AND operation x & y, and assigns it to the first operands’ variable x. This type of in-place operation is also called augmented arithmetic assignment. The method simply returns the new value … Read more

Python __ipow__() Magic Method

Syntax object.__ipow__(self, other) The Python __ipow__() magic method implements the in-place exponentiation x **= y that calculates the result of the power function x ** y, and assignsit to the first operands’ variable x. This type of in-place operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned … Read more

Python __imod__() Magic Method

Syntax object.__imod__(self, other) The Python __imod__() magic method implements the in-place modulo operation x %= y that calculates the modulo operation x % y, and assigns the result to the first operands variable x. This type of in-place operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned … Read more

Python __ifloordiv__() Magic Method

Syntax object.__ifloordiv__(self, other) The Python __ifloordiv__() magic method implements the in-place floor division operation x //= y that calculates the integer division operation x // y, and assigns the result to the first operands variable x. This operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned to … Read more

Python __itruediv__() Magic Method

Syntax object.__itruediv__(self, other) The Python __itruediv__() magic method implements the in-place division operation x /= y that calculates the division operation x / y, and assigns the result to the first operands variable x. This operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned to the first … Read more

Python __irshift__() Magic Method

Syntax object.__irshift__(self, other) The Python __irshift__() magic method implements in-place bitwise right-shift operation x >>= y that calculates the right-shift operation x >> y, and assigns the result to the first operands variable x. This operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned to the first … Read more

Python __ilshift__() Magic Method

Syntax object.__ilshift__(self, other) The Python __ilshift__() magic method implements in-place bitwise left-shift operation x <<= y that calculates the left-shift operation x << y, and assigns the result to the first operands variable x. This operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned to the first … Read more

Python __imatmul__() Magic Method

Syntax object.__imatmul__(self, other) The Python __imatmul__() magic method implements in-place matrix multiplication x @= y that calculates the matrix multiplication of the two operands and assigns the result to the left operand. This operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned to the first operand. When … Read more