]> granicus.if.org Git - python/commitdiff
Beautify grouper() recipe in docs.
authorRaymond Hettinger <python@rcn.com>
Tue, 27 Jan 2009 04:57:51 +0000 (04:57 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 27 Jan 2009 04:57:51 +0000 (04:57 +0000)
Doc/library/itertools.rst
Lib/test/test_itertools.py

index 147072146588c4e8b6b9b0af52a53521c6eb651c..618cf7da4757b1343c2d73258e8d173f2d121c1d 100644 (file)
@@ -634,7 +634,7 @@ which incur interpreter overhead.
    def grouper(n, iterable, fillvalue=None):
        "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
        args = [iter(iterable)] * n
-       return zip_longest(fillvalue=fillvalue, *args)
+       return zip_longest(*args, fillvalue=fillvalue)
 
    def roundrobin(*iterables):
        "roundrobin('ABC', 'D', 'EF') --> A D E B F C"
index b1ba8c025caed6613e4924fb39cf4867531d920d..7c858eb97e09735935c651d0bb48af55c4a0c204 100644 (file)
@@ -1370,7 +1370,7 @@ Samuele
 >>> def grouper(n, iterable, fillvalue=None):
 ...     "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
 ...     args = [iter(iterable)] * n
-...     return zip_longest(fillvalue=fillvalue, *args)
+...     return zip_longest(*args, fillvalue=fillvalue)
 
 >>> def roundrobin(*iterables):
 ...     "roundrobin('ABC', 'D', 'EF') --> A D E B F C"