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