"By default, __ne__() delegates to __eq__() and inverts the result
unless it is NotImplemented. There are no other implied relationships
among the comparison operators"
whereas the python2 doc [2] says:
"There are no implied relationships among the comparison operators."
I think this behavior change got introduced in python with [3]. As long as
we support python2, a change seems to be reasonable.
I think this is true. I executed this piece of code under different python
versions:
class Resource(object):
def __init__(self, person):
self.person = person
def __eq__(self, other):
return self.person == other.person
r1 = Resource("test")
r2 = Resource("test")
r3 = Resource("test_r3")
r4 = Resource("test_r4")
print(r1 != r2)
print(r1 == r2)
print(r3 != r4)
print(r3 == r4)
Python 2.7.10 Python 3.5.1 ------- ------- ------- --
-------
True False
True True
True True
False False
Also, The python3 doc [1] says:
"By default, __ne__() delegates to __eq__() and inverts the result
unless it is NotImplemented. There are no other implied relationships
among the comparison operators"
whereas the python2 doc [2] says:
"There are no implied relationships among the comparison operators."
I think this behavior change got introduced in python with [3]. As long as
we support python2, a change seems to be reasonable.
References: /docs.python. org/3/reference /datamodel. html#object. __ne__ /docs.python. org/2.7/ reference/ datamodel. html#object. __ne__ bugs.python. org/issue21408
[1] https:/
[2] https:/
[3] http://