Python __invert__() Magic Method
Syntax object.__invert__(self) The Python __invert__() method implements the unary arithmetic operation bitwise NOT ~. So, when you cal ~x, Python will internally call x.__invert__() to obtain the inverted object. If the method is not implemented, Python will raise a TypeError. We call this a “Dunder Method” for “Double Underscore Method” (also called “magic method”). To … Read more