From: Raymond Hettinger Date: Mon, 6 May 2013 02:53:41 +0000 (-0700) Subject: Issue 17862: Improve the signature of itertools grouper() recipe. X-Git-Tag: v3.3.2~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44571daf0e3a1df376dc97551643281bdf2dbcb8;p=python 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. --- diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 1eb554a40a..7099fa031b 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -705,9 +705,9 @@ which incur interpreter overhead. next(b, None) return zip(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 zip_longest(*args, fillvalue=fillvalue)