Author David Seddon
Recipients David Seddon
Date 2015-11-25.13:12:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448457169.16.0.121144285875.issue25732@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation for functools.total_ordering states that rich comparison can be enabled on a class by specifying an __eq__ method, and one of __lt__(), __le__(), __gt__(), or __ge__().  If these instructions are followed, this results in an incorrect evaluation of the not equal operator:

Here's an example:

    from functools import total_ordering

    @total_ordering
    class Value(object):

        def __init__(self, value):
            self.value = value
    
        def __eq__(self, other):
            return self.value == other.value
    
        def __lt__(self, other):
            return self.value < other.value

 
    >>> a = Value(3)
    >>> b = Value(3)
    >>> a == b
    True
    >>> a != b
    True

I've tested this on 2.7.10.
 
Either the documentation or the behaviour should be corrected.

https://docs.python.org/2/library/functools.html#functools.total_ordering
History
Date User Action Args
2015-11-25 13:12:49David Seddonsetrecipients: + David Seddon
2015-11-25 13:12:49David Seddonsetmessageid: <1448457169.16.0.121144285875.issue25732@psf.upfronthosting.co.za>
2015-11-25 13:12:49David Seddonlinkissue25732 messages
2015-11-25 13:12:48David Seddoncreate