Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40905 > unrolled thread

Re: itertools doc example "consume"

Started bySkip Montanaro <skip@pobox.com>
First post2013-03-08 21:43 +0000
Last post2013-03-08 21:43 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: itertools doc example "consume" Skip Montanaro <skip@pobox.com> - 2013-03-08 21:43 +0000

#40905 — Re: itertools doc example "consume"

FromSkip Montanaro <skip@pobox.com>
Date2013-03-08 21:43 +0000
SubjectRe: itertools doc example "consume"
Message-ID<mailman.3102.1362779016.2939.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web