Alex Waygood <alex.wayg...@gmail.com> added the comment:
The following code now leads to a `DeprecationWarning`, but I am unclear why it should. ``` >>> from enum import Enum >>> >>> class CardColour(Enum): ... """Enumeration of the two colours in a pack of cards.""" ... ... BLACK = 'black' ... RED = 'red' ... ... def other_colour(self): ... """Given one colour, get the other one.""" ... return next(filter(self.__ne__, CardColour)) ... >>> CardColour.BLACK.other_colour() <input>:5: DeprecationWarning: NotImplemented should not be used in a boolean context <CardColour.RED: 'red'> ``` If I change the last line of `other_colour` to either `return next(colour for colour in CardColour if colour != self)` or `return next(colour for colour in CardColour if colour is not self)`, the warning goes away. Is this intended behaviour? ---------- nosy: +AlexWaygood _______________________________________ 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