Ian Bicking: the old part of his blog


I agree with the original point, and I can well imagine myself using slice/array notation and indexes with strings rather than directly iterating over the "characters", although I typically avoid character manipulation and try and use string methods wherever possible. Indeed, because of various stated benefits of using lists for such manipulations, one could legitimately argue that people should convert to lists, do their stuff, and then convert back to strings afterwards, all without having "string iteration". Moreover, if one does anything to a string when iterating over it, one has to store the transformed characters somewhere other than the original string anyway, due to its immutability.

If you consider the C-style motivation for this feature, which is iterating over a character array using pointers, I'd claim that such antics borders on the "un-Pythonic", although that claim might only stick because of the primitive syntax in C for iterating in such a way: the ++ and -- operators. But non-const character arrays in C are at least mutable and do justify such trickery when being modified in place.
Comment on Python nit, chapter 3
by Paul Boddie