These special methods allow your class to specify what
happens when comparison operators such as “
<=” are used, and the left-hand
operator is an instance of your class. (In most cases
the right-hand operator is also an instance of the same
class, but this is not actually required.)
In each case, the calling sequence for the method must look like this:
__method__(self, other): ...
self argument is the left-hand
operand and the
other argument is the
operand on the right hand of the operator.
Each method must return a numeric value:
A negative number indicates that
Zero indicates that
other are considered equal.
A positive number indicates that
If the method does not implement the operation, it
may return the special value