[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-04-02 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Thanks!  :-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-04-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Thanks Cheryl.  This was nice work :-)

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-04-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset 325191bd6b3a2d5e3012adee868f19baf3e2c3ab by Raymond Hettinger 
(Cheryl Sabella) in branch '2.7':
[2.7] bpo-27212: Modify islice recipe to consume initial values preceding start 
(GH-6195) (GH-6339)
https://github.com/python/cpython/commit/325191bd6b3a2d5e3012adee868f19baf3e2c3ab


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-04-01 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
pull_requests: +6051

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-03-26 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset c8698cff7ccc8dc730c58523c7ef4113ea8d3049 by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.6':
bpo-27212: Modify islice recipe to consume initial values preceding start 
(GH-6195) (GH-6267)
https://github.com/python/cpython/commit/c8698cff7ccc8dc730c58523c7ef4113ea8d3049


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-03-26 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset f328caf4caafd4521c356af8cb8a299f27603c90 by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.7':
bpo-27212: Modify islice recipe to consume initial values preceding start 
(GH-6195) (#GH-6266)
https://github.com/python/cpython/commit/f328caf4caafd4521c356af8cb8a299f27603c90


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-03-26 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5992

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-03-26 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5991

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-03-26 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset da1734c58d2f97387ccc9676074717d38b044128 by Raymond Hettinger 
(Cheryl Sabella) in branch 'master':
bpo-27212: Modify islice recipe to consume initial values preceding start 
(GH-6195)
https://github.com/python/cpython/commit/da1734c58d2f97387ccc9676074717d38b044128


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-03-22 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
keywords: +patch
pull_requests: +5942
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-03-22 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Thanks, Raymond.  I'll take a look.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-03-22 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Cheryl, I think you take this one.  It hasn't been touched in a long time and 
Nofar is focused on another issue.

--
assignee: Nofar Schnider -> csabella

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2018-03-20 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Hi Nofar,

Are you still interested in working on this issue?  Thanks!

--
nosy: +csabella

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2016-09-09 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> Nofar Schnider
nosy: +Nofar Schnider

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2016-09-09 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The recipe should be modified to consume the initial values.  Something like 
this:

start, stop, step = s.start or 0, s.stop or sys.maxsize, s.step or 1
for i in zip(range(0, start), it):
pass

The recipe needs to pass these tests:

it = iter('abcdefghi')
assert list(islice(it, 4, 4)) == []
assert list(it) == ['e', 'f', 'g', 'h', 'i']
assert(list(islice('ABCDEFG', 2)) == ['A', 'B'])
assert(list(islice('ABCDEFG', 2, 4)) == ['C', 'D'])
assert(list(islice('ABCDEFG', 2, None)) == ['C', 'D', 'E', 'F', 'G'])
assert(list(islice('ABCDEFG', 0, None, 2)) == ['A', 'C', 'E', 'G'])

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2016-06-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee: docs@python -> rhettinger
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27212] Doc for itertools, 'islice()' implementation have unwanted behavior for recipe 'consume()'

2016-06-03 Thread alex0307

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com