From: Raymond Hettinger Date: Mon, 6 May 2013 02:45:42 +0000 (-0700) Subject: Issue 17862: Improve the signature of itertools grouper() recipe. X-Git-Tag: v2.7.5~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=277c27c8fce8e58ed22f5aa25627785fb08e4ce4;p=thirdparty%2FPython%2Fcpython.git 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 0e98c1e2adf4..76452811cde7 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -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)