Message402256
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" |
|
Date |
User |
Action |
Args |
2021-09-20 16:24:37 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, terry.reedy, steven.daprano, ethan.furman, josh.r, veky, xtreak, AlexWaygood |
2021-09-20 16:24:36 | serhiy.storchaka | set | messageid: <1632155076.97.0.484059741187.issue35712@roundup.psfhosted.org> |
2021-09-20 16:24:36 | serhiy.storchaka | link | issue35712 messages |
2021-09-20 16:24:36 | serhiy.storchaka | create | |
|