Steven D'Aprano wrote:
> On Sun, Feb 23, 2020 at 11:25:12PM +0200, Alex Hall wrote:
> > "Strings are not iterable - you cannot loop over them
> > or treat them as a
> > collection.
> > Are you implying that we should deprecate the in operator for
> strings 
> too?

I would not get rid of the `in` behavior, but the `in` behavior of a string is 
actually not like that of the `in` operator for a typical collection.  Seen as 
simply a collection of single-character strings, "b" would be in "abcd", but 
"bc" would not. The `in` operator for strings is checking whether the left 
operand is a substring as opposed to an item. `(2, 3)` is not `in` `(1, 2, 3, 
4)`.
_______________________________________________
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/4H2IEA6MNOBH2JKENGLOYIE33O7BT4ST/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to