[Python-3000] Making strings non-iterable

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Apr 17 02:53:46 CEST 2006


Guido van Rossum wrote:

> (I'm surprised by this. Why would s[i] be wrong?)

Because if we're to be consistent about the notion that
a string isn't a sequence of characters, s[i] is really
a slice of length one, and should be expressed that
way.

Also, if len(s) and s[i] are both legal, it becomes
rather surprising if iter(s) doesn't work.

> I think you may be right. I implemented this (it was really simple to
> do) but then found I had to fix tons of places that iterate over
> strings.

I wonder if the stdlib might be a bit unusual here,
since it's the place where low-level things are
implemented. I don't think there would be many places
in my code that would be affected, but others'
experiences may be different.

--
Greg


More information about the Python-3000 mailing list