The comparison of arbitrary objects is called "rich comarisons". There is some documentation here, and here.
If you are working with Python 3, then check this out. Relevant quote from this source:
Having both the rich comparison methods and the
__cmp__()
method violates the principle that there should be only one obvious way to do it, so in Python 3 the support for__cmp__()
has been removed. For Python 3 you therefore must implement all of the rich comparison operators if you want your objects to be comparable.