On Mon, Oct 25, 2021 at 9:33 PM Jeremiah Vivian <nohackingofkrowten@gmail.com> wrote:
It's worth noting that "in" is defined by the container. Object identity and equality aren't actually part of the definition. A lot of containers will behave as the OP describes, but strings, notably, do not - if you iterate over "caterpillar", you will never see "cat", yet it is most definitely contained. I've been thinking of the `is in` operator using `in` when the iterable is just a single mass of items, like a string is just a single mass of characters. Is this a good idea?
The operator would exist regardless of what the container is, and it has to have some kind of semantic definition. Not all containers have a concept of equality/identity containment, so it's much better to stick to the existing operator and define your own container or search object with the semantics you want. ChrisA