dict.items() vs dict.iteritems and similar questions

skip at pobox.com skip at pobox.com
Thu Mar 15 13:30:46 EDT 2007


    Duncan> I think I'd prefer the barbaric:

    Duncan>    return len(list(iterator))

    Duncan> since at least it is guaranteed to terminate.

Are you sure?  There's no guarantee that an iterator will terminate:

    len(list(itertools.cycle(range(10))))

Skip



More information about the Python-list mailing list