Constructors and Expressions: __init__, __sub__ common operator overloading methods
| Method |
Reload |
Pager |
| __init__ |
constructor function |
Object creation: X = Class (args) |
| __del__ |
Destructors |
X Object retract |
| __add__ |
Cloud Algorithm + |
If there is no _iadd_, X+y, x+=y |
| __or__ |
operator | |
If there is no _ior_,x| Y, X|=y |
| _REPR__, __str__ |
Print, convert |
Print (x), repr (x), str (x) |
| __call__ |
Function call |
X (*args, **kwargs) |
| __getattr__ |
Point number arithmetic |
x.undefined |
| __setattr__ |
Property Assignment Statements |
X.any=value |
| __delattr__ |
Property Delete |
Del X.any |
| __getattribute__ |
Property gets |
X.any |
| __getitem__ |
Index operations |
X[KEY],X[I:J] |
| __setitem__ |
Index assignment statement |
X[key],x[i:j]=sequence |
| __delitem__ |
Index and Shard deletion |
Del X[key],del X[i:j] |
| __len__ |
Length |
Len (X), if there is no __bool__, the truth test |
| __bool__ |
Boolean test |
BOOL (X) |
__lt__, __gt__, __le__, __ge__, __eq__, __ne__ |
A specific comparison |
X<y,x>y,x<=y,x>=y, X==y,x!=y Note: (lt:less than, gt:greater than, le:less equal, Ge:greater equal, Eq:equal, Ne:not Equal ) |
| __radd__ |
Right addition |
Other+x |
| __iadd__ |
field (Enhanced) addition |
X+=y (or else __add__) |
| __ITER__, __next__ |
Iterative environment |
I=iter (X), Next () |
| __contains__ |
Member Relationship Testing |
Item in X (any iteration possible) |
| __index__ |
Integer value |
Hex (x), Bin (x), Oct (x) |
| __ENTER__, __exit__ |
Environment Manager |
With obj as Var: |
__get__, __set__, __delete__ |
Descriptor Properties |
X.attr, X.attr=value, Del x.attr |
| __new__ |
Create |
Create an object before __init__ |
Python operator Overloading