Ian Bicking: the old part of his blog


'I use "if a in b" a lot to test if a is the substring of b and I find it's very readable and convenient. I think it's probably one benefit of iterable string.'

But that's not iterating the string, it's testing for membership (__contains__).

The point isn't that strings don't have list-like properties, but that iterating over strings is a Python "feature" that gives no real benefits, yet leads to common coding errors.
Comment on Python nit, chapter 3
by Graham Fawcett