[Python-ideas] having a "iterable" built-in

Georg Brandl g.brandl at gmx.net
Thu Apr 30 23:46:37 CEST 2009


Tarek Ziadé schrieb:
> On Thu, Apr 30, 2009 at 12:20 AM, Terry Reedy <tjreedy-noVtnmiAkQo at public.gmane.org> wrote:
>> hasattr(ob, '__iter__')
>>
> 
> Right, that works under Python 3, (It won't cover str under Python 2 though)

The old-style iteration protocol (__getitem__ and __len__) has not
disappeared in Python 3.  It's just that str got its own iterator type.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.




More information about the Python-ideas mailing list