]> granicus.if.org Git - python/commitdiff
Issue 17862: Improve the signature of itertools grouper() recipe.
authorRaymond Hettinger <python@rcn.com>
Mon, 6 May 2013 02:53:41 +0000 (19:53 -0700)
committerRaymond Hettinger <python@rcn.com>
Mon, 6 May 2013 02:53:41 +0000 (19:53 -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 1eb554a40ae3518d9df4d5b4fdccb14de8532e8e..7099fa031b9f48603ac75943e2f94a7d4353138d 100644 (file)
@@ -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)