Issue 1655683: 3.4.1 comparison methods content (original) (raw)
From: Jeffrey Miller <jsmiller@google.com>
At this URL and this section of the reference:
http://docs.python.org/ref/customization.html
3.4.1 Basic Customization
The existing text reads, in part:
""" There are no reflected (swapped-argument) versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, lt() and gt() are each other's reflection, le() and ge() are each other's reflection, and eq() and ne() are their own reflection. """
but is incorrect. Although le and ge are symmetric, as are lt and gt, they are not boolean inverse operations if the arguments are swapped.
Instead the text should pair lt with ge, le with gt .
Correcting the given text, it should read:
""" There are no reflected (swapped-argument) versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, lt() and ge() are each other's reflection, le() and gt() are each other's reflection, and eq() and ne() are their own reflection. """
I cannot see a bug there.
The text doesn't talk about boolean inverse operations, it talks about reflected operations, and defines that term as "to be used when the left argument does not support the operation but the right argument does")
Consider this code:
class A: ... pass ... class B: ... def gt(self, other): ... print "gt" ... return True ... def ge(self, other): ... print "ge" ... return True ... A()<B() gt True
According to your "corrected" text, lack of lt in class A should cause ge of class B to be called. As you can see, it calls gt instead (just as the documentation predicts). Indeed, xx.
Closing the report as invalid.