Raymond Hettinger vze4rx4y at
Tue Jul 15 05:05:33 CEST 2003

"Dan Williams" <dan at> wrote in message
news:vh6q7cl5ifin20 at
> Is there any interest in adding a "Haskellish" take function to
> itertools? I know its easy enough to roll my own, I've been using:
> take = lambda iter, n: [x for x in itertools.islice(iter, 0, n)]

I use:

>>> def take(n, seq):
...     return list(islice(seq, n))

> which works, but I was wondering if it was common enough to get into
> itertools?

It made it to the lastest update of the examples in the docs for itertools.
If there is enough demand, it could go into Py2.4

Raymond Hettinger

More information about the Python-list mailing list