[Python-Dev] itertools addition: getitem()

Steven Bethard steven.bethard at gmail.com
Sun Jul 8 17:56:04 CEST 2007


On 7/8/07, Kevin Jacobs <jacobs at bioinformed.com> <bioinformed at gmail.com> wrote:
> Also vaguely apropos:
>
> def ilen(seq):
>   'Return the length of the hopefully finite sequence'
>   n = 0
>   for x in seq:
>      n += 1
>   return n

Also known as::

    sum(1 for _ in iterable)

That's always been simple enough that I didn't feel a need for an
ilen() function.

STeVe
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy


More information about the Python-Dev mailing list