Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

Interesting, it is because object().__eq__(object()) returns NotImplemented 
instead of False.

object.__eq__ could return False if arguments have same type (or in some other 
cases). I think it would not break anything, and it would fix your case. But I 
am not sure that it is worth to change this. Using bound methods __eq__ and 
__ne__ is an antipattern, and we should not encourage this, even if it is safe 
as in your case. If you want to discuss this more, it is better to do this on a 
mailing-list or Discuss.

Your code can be rewritten as:

    def other_colour(self):
        for other in CardColour:
            if self != other:
                return other
        assert False, "not reachable"

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35712>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to