New submission from alex0307:

In the doc for itertools, the python implementation of islice() doesn't 
actually perform the iteration when given an empty slice (e.g. islice(it,3,3)). 

This is not the expected behavior for 'consume()' in the recipe given below, 
i.e. consume(it,3) couldn't actually advance the iterator for 3 steps ahead. 
Instead, the iterator stays at its starting position.

As a simple fix, in the implementation of islice(), the length of the slice 
object should be checked first. If it's zero, the iterator should be advanced 
(slice.start-1) times, and return (See islice_my.py)

----------
assignee: docs@python
components: Documentation
files: islice_my.py
messages: 267236
nosy: alex0307, docs@python
priority: normal
severity: normal
status: open
title: Doc for itertools, 'islice()' implementation have unwanted behavior for 
recipe 'consume()'
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file43184/islice_my.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27212>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to