Comment 7 for bug 1586268

Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote :

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:
[1] https://docs.python.org/3/reference/datamodel.html#object.__ne__
[2] https://docs.python.org/2.7/reference/datamodel.html#object.__ne__
[3] http://bugs.python.org/issue21408