You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
The doc comment is out of date. The spec was changed relatively recently to makes strings not-iterable, because more often than not, iterating over a string is a mistake. (The usual symptom is that one means to iterate over the list ["foo"] but instead iterates over "foo", yielding the values "f", "o", "o". Because the elements of the iteration have the same type as the sequence as a whole, often the mistake goes unnoticed. The two staff at Google with single-letter userids receive a lot of unintended e-mail sent by errant Python programs.)
Instead of string being iterable, four methods were added to string that return iterable values. This approach also makes the intention more obvious as to whether you're iterating over string elements (bytes) or Unicode code points, and whether numeric values or substrings are desired.
Docs for
String
says:But
String
doesn't implementIterable
'sIterate
method.Is this intentional?
String
could implementIterable
, in theory, by returning an iterator which passes each one-byte substring intoNext
.The text was updated successfully, but these errors were encountered: