Alex Waygood <alex.wayg...@gmail.com> added the comment:
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. ---------- _______________________________________ 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