On Mon, Oct 25, 2021 at 9:33 PM Jeremiah Vivian <nohackingofkrow...@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 _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/I6WWBVD5HU2KVBZXOMULLND7UVN6P3D2/ Code of Conduct: http://python.org/psf/codeofconduct/