This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients AlexWaygood, ethan.furman, josh.r, rhettinger, serhiy.storchaka, steven.daprano, terry.reedy, veky, xtreak
Date 2021-09-20.16:24:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632155076.97.0.484059741187.issue35712@roundup.psfhosted.org>
In-reply-to
Content
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"
History
Date User Action Args
2021-09-20 16:24:37serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, terry.reedy, steven.daprano, ethan.furman, josh.r, veky, xtreak, AlexWaygood
2021-09-20 16:24:36serhiy.storchakasetmessageid: <1632155076.97.0.484059741187.issue35712@roundup.psfhosted.org>
2021-09-20 16:24:36serhiy.storchakalinkissue35712 messages
2021-09-20 16:24:36serhiy.storchakacreate