]> granicus.if.org Git - python/commitdiff
Alter recipe to show how to call izip_longest() with
authorRaymond Hettinger <python@rcn.com>
Thu, 31 Jul 2008 01:19:50 +0000 (01:19 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 31 Jul 2008 01:19:50 +0000 (01:19 +0000)
both a keyword argument and star arguments.

Doc/library/itertools.rst
Lib/test/test_itertools.py

index 6bda2cfa1048c7d952ebd6397d0c13fcf0e112e8..db38e697d7111cb07817da340dbc7aa3dc46843a 100644 (file)
@@ -647,8 +647,7 @@ which incur interpreter overhead.
    def grouper(n, iterable, fillvalue=None):
        "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
        args = [iter(iterable)] * n
-       kwds = dict(fillvalue=fillvalue)
-       return izip_longest(*args, **kwds)
+       return izip_longest(fillvalue=fillvalue, *args)
 
    def roundrobin(*iterables):
        "roundrobin('ABC', 'D', 'EF') --> A D E B F C"
index f6174ab63d1da9f2af7da3c03a7987a2c1cbec79..6912ac74215767cb4c68ca43b1a1281cab6adcaf 100644 (file)
@@ -1236,8 +1236,7 @@ Samuele
 >>> def grouper(n, iterable, fillvalue=None):
 ...     "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
 ...     args = [iter(iterable)] * n
-...     kwds = dict(fillvalue=fillvalue)
-...     return izip_longest(*args, **kwds)
+...     return izip_longest(fillvalue=fillvalue, *args)
 
 >>> def roundrobin(*iterables):
 ...     "roundrobin('ABC', 'D', 'EF') --> A D E B F C"