Commit 277c27c8 authored by Raymond Hettinger's avatar Raymond Hettinger

Issue 17862: Improve the signature of itertools grouper() recipe.

Putting *n* after the *iterable* matches the signature of other itertools
and recipes.  Also, it reads better.

Suggested by Ezio Melotti.
parent 6a4f3941
......@@ -732,9 +732,9 @@ which incur interpreter overhead.
next(b, None)
return izip(a, b)
def grouper(n, iterable, fillvalue=None):
def grouper(iterable, n, fillvalue=None):
"Collect data into fixed-length chunks or blocks"
# grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx
args = [iter(iterable)] * n
return izip_longest(fillvalue=fillvalue, *args)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment