[Python-3000] Making strings non-iterable

Giovanni Bajo rasky at develer.com
Thu Apr 13 20:57:02 CEST 2006


Ian Bicking <ianb at colorstudy.com> wrote:

> I propose that strings (unicode/text) shouldn't be iterable.  Seeing this:
>
> <ul>
>   <li> i
>   <li> t
>   <li> e
>   <li> m
>   <li>
>   <li> 1
> </ul>
>
> a few too many times... it's annoying.  Instead, I propose that strings
> get a list-like view on their characters.  Oh synergy!
>
> Thus you would do:
>
>    for c in a_string.chars():
>        print c

Would this remove __getitem__? I believe I wouldn't want to give up s[0] as
"the first character in s". That would make a string a thing where you can
use [3] to access the third character, but still not iterable.
-- 
Giovanni Bajo



More information about the Python-3000 mailing list