[Python-Dev] Rich comparison confusion

Christian Tismer tismer@tismer.com
Fri, 19 Jan 2001 17:17:06 +0100


Guido van Rossum wrote:
> 
> > Yes, the "inverse" is confusing. Is what you mean the "reverse" ?
> > Like the other right-side operators __radd__, is it correct to
> > think of
> >
> >    __ge__  == __rle__
> >
> > if __rle__ was written in the same fashion like __radd__ ?
> > It looks semantically the same, although the reason for a
> > call might be different.
> 
> Yes, it's semantically the same, and the reason for the call is the
> same too ("the left argument doesn't support the operator so let's try
> if the right one knows").
> 
> > And if my above view is right, would it perhaps be less
> > confusing to use in fact __rle__ and __rlt__,
> > or woudl it be more confusing, since __rlt__ would also be
> > invoked left-to-right, implementing ">".
> 
> I prefer 6 new operators over 12 any day.  I can see no valid reason
> why someone would want to overload a>b different than b<a, while
> there are plenty of reasons why a+b and b+a should be different:
> e.g. string concatenation.

Sure, I didn't want to introduce new operators, but use the
"r" versions for three of the six new operators. But I should have
read you proposal before. The confusion is not due to you,
but Skip had a read error, since you don't talk about inverses
at all:

Skip=="""
In the description
he states that __le__ and __ge__ are inverses as are __lt__ and __gt__.
"""

Truth=="""
There are no explicit "reversed argument" versions of
  these; instead, __lt__ and __gt__ are each other's reverse, likewise
  for__le__ and __ge__; __eq__ and __ne__ are their own reverse
  (similar at the C level).
"""

No reason for confusion at all > python-dev/null - ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer@tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com