__init__ method the derived class's __init__ method must
explicitly call it to ensure proper initialization of the base class
part of the instance.
__del__ method the derived class's __del__ method
must explicitly call it to ensure proper deletion of the base class
part of the instance. Note that it is possible for the __del__
method to postpone destruction of the instance by creating a new
reference to it. It may then be called at a later time when this new
reference is deleted. It is not guaranteed that
__del__ methods are called for objects that still exist when
the interpreter exits.
Note that del x doesn't directly call x.__del__ --- the
former decrements the reference count for x by one, but
x.__del__ is only called when its reference count reaches zero.
repr() built-in function and by string conversions
(reverse or backward quotes) to compute the string representation of an object.
str() built-in function and by the print
statement compute the string representation of an object.
self < other, 0 if self == other, +1 if
self > other. If no __cmp__ operation is defined, class
instances are compared by object identity (``address'').
(Implementation note: due to limitations in the interpreter,
exceptions raised by comparisons are ignored, and the objects will be
considered equal in this case.)
hash(). Should return a 32-bit integer usable as a hash value
for dictionary operations. The only required property is that objects
which compare equal have the same hash value; it is advised to somehow
mix together (e.g. using exclusive or) the hash values for the
components of the object that also play a part in comparison of
objects. If a class does not define a __cmp__ method it should
not define a __hash__ operation either; if it defines
__cmp__ but not __hash__ its instances will not be
usable as dictionary keys. If a class defines mutable objects and
implements a __cmp__ method it should not implement
__hash__, since the dictionary implementation assumes that a
key's hash value is a constant.