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?
Strings *are* collections:
py> import collections.abc
py> isinstance("spam", collections.abc.Collection)
True
Strings aren't atomic values: they contain substrings. They can be
sliced. We can ask whether one string contains another: strings are
containers as well as collections.
Sometimes we treat strings as if they were pseudo-atomic. And
sometimes we treat tuples as pseudo-atomic records too. Should tuples no
longer be iterable? I don't think so.
--
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/ZQIJFXNLIO3HSSSKGFHPSX4RYHDP24FL/
Code of Conduct: http://python.org/psf/codeofconduct/