]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Beautify grouper() recipe in docs.
authorRaymond Hettinger <python@rcn.com>
Tue, 27 Jan 2009 05:00:57 +0000 (05:00 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 27 Jan 2009 05:00:57 +0000 (05:00 +0000)
Doc/library/itertools.rst
Lib/test/test_itertools.py

index ba6ab1c327458c98b4449970bc4bf37fc856f638..f0bb251602efc2afc72f083a5585b00f044af3fc 100644 (file)
@@ -573,7 +573,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 7023b293bf047a003825fb45f9883304ea36f0e1..a675052cd875c0f9683591892f73a89ccd7f86bf 100644 (file)
@@ -1261,7 +1261,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"