Dec-20-2020, 03:00 AM
No way to redefine it that I'm aware of.
Given that, I would just redo your test as the same comprehension, just without the equality test.
Quote:For container types such as list, tuple, set, frozenset, dict, or collections.deque, the expressionx in y
is equivalent toany(x is e or x == e for e in y)
.
Given that, I would just redo your test as the same comprehension, just without the equality test.
>>> item = 1 >>> mylist = [True] >>> item in mylist True >>> any(x is item for x in mylist) False