[Python-3000] Making strings non-iterable

Jim Jewett jimjjewett at gmail.com
Thu Apr 13 20:35:50 CEST 2006


On 4/13/06, Ian Bicking <ianb at colorstudy.com> wrote:
> I propose that strings (unicode/text) shouldn't be iterable.

I understand that there are use cases, but I can't remember seeing one
in real life.  I have seen many uses for the container version

    x in string

and of course many good uses of iteration over the results of a string
method (such as string.split()), but no good uses for iterating over a
string directly

    for x in string

A special method to get a tuple (or immutable list) view would be a
good thing, as it would document that I was doing so intentionally. 
(I wouldn't want to give up slicing, though, which might make the
no-iteration trickier.)

-jJ


More information about the Python-3000 mailing list