[Python-ideas] An exhaust() function for iterators

Georg Brandl g.brandl at gmx.net
Sun Sep 29 07:47:38 CEST 2013


Am 29.09.2013 06:06, schrieb Clay Sweetser:

> I would like to propose that this function, or one very similar to it,
> be added to the standard library, either in the itertools module, or
> the standard namespace.
> If nothing else, doing so would at least give a single *obvious* way
> to exhaust an iterator, instead of the several miscellaneous methods
> available.

YAGNI.  This is not a very common operation.

On the point of obvious ways, the first one you gave

for _ in iterable:
    pass

is perfectly obvious and simple enough AFAICS.

cheers,
Georg




More information about the Python-ideas mailing list