A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-June/080106.html below:

[Python-Dev] Assumed reflexivity of rich comparison operators

[Python-Dev] Assumed reflexivity of rich comparison operatorsJared Flatow jflatow at northwestern.edu
Fri Jun 6 22:10:58 CEST 2008
Hi all,

PEP 207 (http://www.python.org/dev/peps/pep-0207/) states in the  
fourth clause of the proposed resolutions to concerns:

"The reflexivity rules *are* assumed by Python.  Thus, the interpreter  
may swap y>x with x<y, y>=x with x<=y, and may swap the arguments of  
x==y and x!=y."

However, if this is the case, why does Python allow the definition of  
both pairs of __le__, __ge__ and __lt__, __gt__ for a single class,  
since users have no guarantee over which will be called? Currently, if  
I do not want x >= y to mean the same thing as y <= x (and believe it  
or not I believe I have a good use case for doing this), there is no  
reliable way of doing this. However, if the decision is to not allow  
users to do this at all using operators (and force them to create  
specially named methods), what is the point of allowing the definition  
of both? It seems very confusing to me (and indeed I was at first very  
confused what was going on), to tempt users to be able to define both  
but give no promise that if they do, the appropriate one will be  
called. Does anyone have a good explanation for this?

Thanks!
jared

More information about the Python-Dev mailing list

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