[New-bugs-announce] [issue27384] itertools islice consumes items when given negative range
report at bugs.python.org
Fri Jun 24 15:13:32 EDT 2016
New submission from Matthew Malcomson:
While the itertools.islice(iterator, n, n) trick is useful as used in the consume recipe, I find the current behaviour if stop is less than start (e.g. itertools.islice(iterator, 3, 0) ) to be surprising.
It still consumes the first three elements of the iterator, in the same manner as when start and stop are equal.
This is what the documentation implies, but I don't know whether that coincidence is by accident or design.
I would expect an iterator that immediately raises StopIteration but doesn't consume anything, but whether that's what most people would expect or not is another matter.
This would match the python version of islice() in the documentation, though I realise that implementation already diverges from the actual one via Issue 27212 .
components: Library (Lib)
nosy: Matthew Malcomson
title: itertools islice consumes items when given negative range
versions: Python 3.6
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce