itertools.take?

Discussion in 'Python' started by Dan Williams, Jul 15, 2003.

  1. Dan Williams

    Dan Williams Guest

    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
     
    Dan Williams, Jul 15, 2003
    #1
    1. Advertising

  2. "Dan Williams" <> wrote in message
    news:...
    > 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
     
    Raymond Hettinger, Jul 15, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    874
  2. Ronald Legere

    Itertools

    Ronald Legere, Jul 29, 2003, in forum: Python
    Replies:
    8
    Views:
    520
    Ng Pheng Siong
    Aug 8, 2003
  3. Steven Bethard
    Replies:
    0
    Views:
    399
    Steven Bethard
    Mar 12, 2005
  4. Raymond Hettinger
    Replies:
    17
    Views:
    552
    Simon Brunning
    Feb 18, 2008
  5. Nick Mellor
    Replies:
    35
    Views:
    363
    Paul Rubin
    Dec 6, 2012
Loading...

Share This Page