[Python-Dev] bool(iter([])) changed between 2.3 and 2.4

Christos Georgiou tzot at mediconsa.com
Thu Oct 20 23:51:10 CEST 2005


"Guido van Rossum" <guido at python.org> wrote in message 
news:ca471dc205092017071f2eb1e8 at mail.gmail.com...
>> [Fred]
>> > think iterators shouldn't have length at all:
>> > they're *not* containers and shouldn't act that way.
>>
>> Some iterators can usefully report their length with the invariant:
>>    len(it) == len(list(it)).
>
>I still consider this an erroneous hypergeneralization of the concept
>of iterators. Iterators should be pure iterators and not also act as
>containers. Which other object type implements __len__ but not
>__getitem__?

Too late, and probably irrelevant by now; the answer though is

set([1,2,3]) 




More information about the Python-Dev mailing list