Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23695
___
Roundup Robot added the comment:
New changeset f7d82e40e472 by Raymond Hettinger in branch 'default':
Issue #23695: Explain the zip() example for clustering a data series into
n-length groups.
https://hg.python.org/cpython/rev/f7d82e40e472
--
nosy: +python-dev
R. David Murray added the comment:
I think it would be both helpful and sufficient to add a gloss, perhaps
something like: this passes zip ``n`` references to the *same* iterator, which
means zip calls that single iterator ``n`` times for each tuple it creates; zip
thus outputs tuples
Paddy McCarthy added the comment:
I like R. David Murray's suggestion, but I am also aware of how it works and so
cannot judge how it would look to the intermediate Python programmer who knows
iterators and zip, but is new to this grouper; (who I think should be the
target audience).
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
assignee: docs@python - rhettinger
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23695
___
Paddy McCarthy added the comment:
Hmmm. It seems that the problem isn't to do with the fact that it works, or how
to apply it; the problem is with *how* it works.
Making it an idiom means that too many will use it without knowing why it works
which could lead to later maintenance issues. I
Ethan Furman added the comment:
I think an example should suffice:
s = [1, 2, 3, 4, 5, 6, 7, 8, 9]
n = 3
zip(*[iter(s)]*n)
[(1, 2, 3), (4, 5, 6), (7, 8, 9)]
--
nosy: +ethan.furman
versions: -Python 3.2, Python 3.3
___
Python tracker
New submission from Paddy McCarthy:
In the zip section of the documentation, e.g.
https://docs.python.org/3/library/functions.html#zip There is mention of an
idiom for clustering a data series into n-length groups that I seem to only
come across when people are explaining how it works on blog