itertools doc example "consume"
skip at pobox.com
Fri Mar 8 22:43:21 CET 2013
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...
More information about the Python-list