consume¶

iteration_utilities.
consume
(iterator, n)¶ Advance the iterator nsteps ahead. If n is
None
, consume entirely. Parameters
 iteratoriterator
Any iterator from which to consume the items.
 n
int
or None Number of items to consume from the iterator. If
None
consume it entirely.
Examples
>>> from iteration_utilities import consume >>> g = (x**2 for x in range(10)) >>> consume(g, 2) >>> list(g) [4, 9, 16, 25, 36, 49, 64, 81]
>>> g = (x**2 for x in range(10)) >>> consume(g, None) >>> list(g) []