Terry Reedy wrote: > "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> FWIW, the iterator protocol appeared with Python 2.2. Before this >> version, the above solution was the only one that allowed iteration over >> a container type. >> >> Now if you wonder why string, unicode and buffer don't have __iter__ >> while other sequence types have it, ask your favourite Python guru (and >> please keep me informed !-). > > Giving that Python still has to support the old __getitem__ protocol in for > statements, there was no need to rewrite stuff that worked and no one did > so for those types.
What I wonder here is why __iter__ has been added to lists and tuples but not to strings (not that I'm complaining, it's just curiousity...) > The emergent problem of identifying an 'iterable' had > been noted and Guido has, I believe, approved the addition of '__iter__' to > those types for 2.6. (But someone still has to write the patches ;-) Which is a GoodThing(tm) wrt/ consistency - and makes clear I should not have talked about the hasattr(obj, '__iter__') hack. -- http://mail.python.org/mailman/listinfo/python-list