| Method | Description |
|---|---|
| new(cls, other) | To get called in an object's instantiation. |
| init(self, other) | To get called by the __new__ method. |
| del(self) | Destructor method. |
| Method | Description |
|---|---|
| pos(self) | To get called for unary positive e.g. +someobject. |
| neg(self) | To get called for unary negative e.g. -someobject. |
| abs(self) | To get called by built-in abs() function. |
| invert(self) | To get called for inversion using the ~ operator. |
| round(self,n) | To get called by built-in round() function. |
| trunc(self) | To get called by built-in math.trunc() function. |
| floor(self) | To get called by built-in math.floor() function. |
| ceil(self) | To get called by built-in math.ceil() function. |
| Method | Description |
|---|---|
| iadd(self, other) | To get called on addition with assignment e.g. a +=b. |
| isub(self, other) | To get called on subtraction with assignment e.g. a -=b. |
| imul(self, other) | To get called on multiplication with assignment e.g. a *=b. |
| ifloordiv(self, other) | To get called on integer division with assignment e.g. a //=b. |
| idiv(self, other) | To get called on division with assignment e.g. a /=b. |
| itruediv(self, other) | To get called on true division with assignment |
| imod(self, other) | To get called on modulo with assignment e.g. a%=b. |
| ipow(self, other) | To get called on exponentswith assignment e.g. a **=b. |
| ilshift(self, other) | To get called on left bitwise shift with assignment e.g. a<<=b. |
| irshift(self, other) | To get called on right bitwise shift with assignment e.g. a >>=b. |
| iand(self, other) | To get called on bitwise AND with assignment e.g. a&=b. |
| ior(self, other) | To get called on bitwise OR with assignment e.g. a |
| ixor(self, other) | To get called on bitwise XOR with assignment e.g. a ^=b. |
| Method | Description |
|---|---|
| int(self) | To get called by built-int int() method to convert a type to an int. |
| float(self) | To get called by built-int float() method to convert a type to float. |
| complex(self) | To get called by built-int complex() method to convert a type to complex. |
| oct(self) | To get called by built-int oct() method to convert a type to octal. |
| hex(self) | To get called by built-int hex() method to convert a type to hexadecimal. |
| index(self) | To get called on type conversion to an int when the object is used in a slice expression. |
| trunc(self) | To get called from math.trunc() method. |
| Method | Description |
|---|---|
| str(self) | To get called by built-int str() method to return a string representation of a type. |
| repr(self) | To get called by built-int repr() method to return a machine readable representation of a type. |
| unicode(self) | To get called by built-int unicode() method to return an unicode string of a type. |
| format(self, formatstr) | To get called by built-int string.format() method to return a new style of string. |
| hash(self) | To get called by built-int hash() method to return an integer. |
| nonzero(self) | To get called by built-int bool() method to return True or False. |
| dir(self) | To get called by built-int dir() method to return a list of attributes of a class. |
| sizeof(self) | To get called by built-int sys.getsizeof() method to return the size of an object. |
| Method | Description |
|---|---|
| getattr(self, name) | Is called when the accessing attribute of a class that does not exist. |
| setattr(self, name, value) | Is called when assigning a value to the attribute of a class. |
| delattr(self, name) | Is called when deleting an attribute of a class. |
| Method | Description |
|---|---|
| add(self, other) | To get called on add operation using + operator. |
| sub(self, other) | To get called on subtraction operation using - operator. |
| mul(self, other) | To get called on multiplication operation using * operator. |
| floordiv(self, other) | To get called on floor division operation using // operator. |
| truediv(self, other) | To get called on division operation using / operator. |
| mod(self, other) | To get called on modulo operation using % operator. |
| pow(self, other[, modulo]) | To get called on calculating the power using ** operator. |
| lt(self, other) | To get called on comparison using < operator. |
| le(self, other) | To get called on comparison using <= operator. |
| eq(self, other) | To get called on comparison using == operator. |
| ne(self, other) | To get called on comparison using != operator. |
| ge(self, other) | To get called on comparison using >= operator. |