Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > itertools.take?

Reply
Thread Tools

itertools.take?

 
 
Dan Williams
Guest
Posts: n/a
 
      07-15-2003
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)]

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

-Dan

 
Reply With Quote
 
 
 
 
Raymond Hettinger
Guest
Posts: n/a
 
      07-15-2003

"Dan Williams" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments