string: __iter__()?

mrquantum mrquantum at holon.at
Wed Oct 4 05:59:07 EDT 2006


Hello!

Just for curiosity i'd like to know why strings don't support the
iteration protocoll!? Is there some deeper reason for this?

>>> hasattr('SomeString', '__iter__')
False

In Python 2.5 it's actually simple to obtain one:

>>> myIter = (c for c in 'SomeString')
>>> myIter.next()
'S'

Thanks for info!

Chris



More information about the Python-list mailing list