[Python-3000] Making strings non-iterable
steven.bethard at gmail.com
Thu Apr 13 20:16:27 CEST 2006
On 4/13/06, Ian Bicking <ianb at colorstudy.com> wrote:
> I propose that strings (unicode/text) shouldn't be iterable. Seeing this:
> <li> i
> <li> t
> <li> e
> <li> m
> <li> 1
> a few too many times... it's annoying. Instead, I propose that strings
> get a list-like view on their characters.
+1. I don't know how many times I wished I'd gotten an error here
instead. I do need to iterate over the characters of a string
occasionally, but not often enough to worry about typing a few extra
> * .chars() doesn't return characters; should it be named something else?
I say leave this one up to Guido. I'm happy with chars because it
does return characters, as long as we define characters as
> * Should it be a method that is called?
I think this is actually a general question about views. Should views
be created with methods or properties? I'm inclined towards the
former, but I think this discussion should be carried out in a
> * Are there other views on strings? Can string->byte encoding be
> usefully seen as a view in some cases?
I refuse to answer this question on the grounds that it may incriminate me. ;-)
Grammar am for people who can't think for myself.
--- Bucky Katt, Get Fuzzy
More information about the Python-3000