Iteration of strings
Alex Martelli
aleax at aleax.it
Fri Nov 22 18:09:06 EST 2002
Bjarke Dahl Ebert wrote:
...
> I think the current situation makes the described script bug ("for x in
> strlist:" when strlist is a string) pass too silently. Often it results in
> code that "works", because a string is effectively also a list of strings.
Yes. I count that as a slight wart of Python. String slices are often
handy, but if strings were "sliceable but not iterable" perhaps Python
would be a netter language.
> What do you think?
It's too late to fix, of course -- any fix would break working code
(although it might conceivably be eased in slowly via "future import").
But it may be an idea for the mythical "Python 3000" that will be allowed to
break compatibility (basically the analog of the Lord Maitreya...).
Alex
More information about the Python-list
mailing list