__lt__(self, other)

New in version 2.1. These are the so-called rich comparison methods, and are called for comparison operators in preference to __cmp__() below. The correspondence between operator symbols and method names is as follows: x&lt;y calls x.\_\_lt\_\_(y), ` x<=ycalls x.__le__(y), x==ycalls x.__eq__(y), x!=yand x<>ycall x.__ne__(y), x>ycalls x.__gt__(y), and x>=ycalls x.__ge__(y)`. These methods can return any value, but if the comparison operator is used in a Boolean context, the return value should be interpretable as a Boolean value, else a TypeError will be raised. By convention, False is used for false and True for true.

There are no implied relationships among the comparison operators. The truth of x==y does not imply that x!=y is false. Accordingly, when defining __eq__(), one should also define __ne__() so that the operators will behave as expected.

There are no reflected (swapped-argument) versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other's reflection, __le__() and __ge__() are each other's reflection, and __eq__() and __ne__() are their own reflection.

Arguments to rich comparison methods are never coerced. A rich comparison method may return NotImplemented if it does not implement the operation for a given pair of arguments.