23 Feb
2020
23 Feb
'20
10:23 p.m.
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