Re: itertools doc example "consume"

Discussion in 'Python' started by Skip Montanaro, Mar 8, 2013.

  1. Ian Kelly <ian.g.kelly <at> gmail.com> writes:

    > Depending on your Python version lst is either a range object or a
    > list, neither of which is an iterator. If you pass to consume an
    > iterable object that is not an iterator, it will implicitly obtain an
    > iterator for it, consume from the iterator, and then discard the
    > iterator, with no effect on the original object.
    >
    > In general the itertools functions will work equally well on iterators
    > and other iterables, but consume is special in that what it does is
    > only relevant to iterators.


    Thanks for the explanation. I clearly still need to grapple with this
    stuff a bit...

    Skip
    Skip Montanaro, Mar 8, 2013
    #1
    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. Matt
    Replies:
    3
    Views:
    500
    Tor Iver Wilhelmsen
    Sep 17, 2004
  2. Steven Bethard
    Replies:
    0
    Views:
    394
    Steven Bethard
    Mar 12, 2005
  3. Raymond Hettinger
    Replies:
    17
    Views:
    546
    Simon Brunning
    Feb 18, 2008
  4. Skip Montanaro

    itertools doc example "consume"

    Skip Montanaro, Mar 8, 2013, in forum: Python
    Replies:
    0
    Views:
    78
    Skip Montanaro
    Mar 8, 2013
  5. Ian Kelly

    Re: itertools doc example "consume"

    Ian Kelly, Mar 8, 2013, in forum: Python
    Replies:
    0
    Views:
    96
    Ian Kelly
    Mar 8, 2013
Loading...

Share This Page