[Python-3000] callable()

Raymond Hettinger rhettinger at ewtllc.com
Thu Jul 20 18:38:06 CEST 2006


Guido van Rossum wrote:

>On 7/20/06, Walter Dörwald <walter at livinglogic.de> wrote:
>  
>
>>str and unicode don't have __iter__, list, tuple and dict do:
>>    
>>
>[...]
>  
>
>>Should that be fixed too?
>>    
>>
>
>Yes, please. (In Python 2.6 if you can.)
>
>  
>

Why is the a defect?  Have we abandoned the notion of SeqIter 
automatically wrapping any object with __getitem__()?

IIRC, list and tuple have __iter__ simply as optimizations, it did not 
change their functionality.


Raymond


-----------------
 >>> class X:
    def __getitem__(self, i):
        if i < 5:
            return i*5
        raise IndexError

   
 >>> for i in X():
    print i

   
0
5
10
15
20


More information about the Python-3000 mailing list