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) messages: 269206 nosy: Matthew Malcomson priority: normal severity: normal status: open title: itertools islice consumes items when given negative range type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27384> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com