[Python-Dev] Rich comparison confusion

Skip Montanaro skip@mojam.com (Skip Montanaro)
Wed, 17 Jan 2001 09:17:39 -0600 (CST)

I'm a bit confused about Guido's rich comparison stuff.  In the description
he states that __le__ and __ge__ are inverses as are __lt__ and __gt__.
>From a boolean standpoint this just can't be so.  Guido mentions partial
orderings, but I'm still confused.  Consider this example: Objects of type A
implement rich comparisons.  Objects of type B don't.  If my code looks like

    a = A()
    b = B()
    if b < a:

My interpretation of the rich comparison stuff is that either

    1. Since b doesn't implement rich comparisons, the interpreter falls
       back to old fashioned comparisons which may or may not allow the
       comparison of B objects and A objects.


    2. The sense of the inequality is switched (a > b) and the rich
       comparison code in A's implementation is called.

That's my reading of it.  It has to be wrong.  The inverse comparison should
be a >= b, not a > b, but the described pairing of comparison functions
would imply otherwise.

I'm sure I'm missing something obvious or revealing some fundamental failure
of my grade school education.  Please explain...