]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue 17862: Improve the signature of itertools grouper() recipe.
authorRaymond Hettinger <python@rcn.com>
Mon, 6 May 2013 02:45:42 +0000 (19:45 -0700)
committerRaymond Hettinger <python@rcn.com>
Mon, 6 May 2013 02:45:42 +0000 (19:45 -0700)
Putting *n* after the *iterable* matches the signature of other itertools
and recipes.  Also, it reads better.

Suggested by Ezio Melotti.

Doc/library/itertools.rst

index 0e98c1e2adf469054abaf96a23430606e1e165db..76452811cde7b9be58d6f73ada4d5adda84fb10e 100644 (file)
@@ -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)