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 AlexWaygood
Recipients AlexWaygood, ethan.furman, josh.r, rhettinger, serhiy.storchaka, steven.daprano, terry.reedy, veky, xtreak
Date 2021-09-20.16:10:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632154245.37.0.712235461518.issue35712@roundup.psfhosted.org>
In-reply-to
Content
Thanks, Vedran. I read https://bugs.python.org/issue35712#msg349303 before adding my message, but am not quite clear why my snippet is the same situation. 

`next(filter((2).__eq__, 'text'))` surely returns 't' because `(2).__eq__('t')` returns `NotImplemented`, and `NotImplemented` is truthy. (Apologies if my understanding is wrong here.)

I'm unclear, however, why `x.__ne__(y)` should ever return `NotImplemented` (or even have the possibility of returning `NotImplemented`) if it is known that both `x` and `y` are members of the same `Enum`. The documentation for `Enum`s clearly states that equality comparisons between members of the same enum are defined (https://docs.python.org/3/library/enum.html#comparisons).

If the argument is "filter should never be used with a predicate that could return `NotImplemented` in some situations", then I think that could usefully be added to the documentation for `filter`. Moreover, if that is the argument, then I don't understand why the following does not raise a DeprecationWarning:

```
>>> next(filter((2).__eq__, (2, 3, 4)))
2
```

Again, apologies if I'm missing something here.
History
Date User Action Args
2021-09-20 16:10:45AlexWaygoodsetrecipients: + AlexWaygood, rhettinger, terry.reedy, steven.daprano, ethan.furman, serhiy.storchaka, josh.r, veky, xtreak
2021-09-20 16:10:45AlexWaygoodsetmessageid: <1632154245.37.0.712235461518.issue35712@roundup.psfhosted.org>
2021-09-20 16:10:45AlexWaygoodlinkissue35712 messages
2021-09-20 16:10:45AlexWaygoodcreate