28 Oct
2021
28 Oct
'21
12:06 p.m.
On Thu, Oct 28, 2021 at 05:25:52PM +1100, Chris Angelico wrote:
But the "in" operator isn't built on iteration, so that would be in-consistent.
"In-"consistent, heh :-)
\>\>\> a = iter("abcde") \>>> a.__contains__ Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'str_iterator' object has no attribute '__contains__' \>>> 'b' in a True \>>> list(a) ['c', 'd', 'e']
https://docs.python.org/3/reference/expressions.html#membership-test-operati...
The "in" operator is built on iteration, but can be overridden by the `__contains__` method.
What you're asking for can best be spelled with any/all and iteration, not a new operator.
I completely agree. I was replying to this.