A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2001-January/011759.html below:

[Python-Dev] Rich comparison confusion

[Python-Dev] Rich comparison confusionSkip 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.

    or

    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...

Skip




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4