Possible Duplicate:
Special (magic) methods in Python
who can tell me what can call the built-in functions in next code
I have being using python and every now and then I discover an implicit class method of the type __xyz__
which holds a special meaning and is over-rided for custom usages.
For example:
class some_class:
def __init__(self):
# Everyone knows about this. [ Constructor ]
pass
def __str__(self):
# string representation of object I suppose.
pass
def __unicode__(self):
# Unicode representation of object I guess
pass
def __del__(self):
# Similar to destructor
pass
These all available over-ridables are useful, but I am not able to find how to refer them or find a documentation of all such available __xyz__
types available in a python class.
What all __xyz__
stuff is available and how do you use them to make your life easy ?
What is the pythonic zen
behind this ?
What are the analogous counterparts in other languages such as C++ ?