From: Raymond Hettinger Date: Thu, 31 Jul 2008 01:19:50 +0000 (+0000) Subject: Alter recipe to show how to call izip_longest() with X-Git-Tag: v2.6b3~196 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f080e6d7e027c9576814dd57af3122ab2aff7aa9;p=python Alter recipe to show how to call izip_longest() with both a keyword argument and star arguments. --- diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 6bda2cfa10..db38e697d7 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -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" diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index f6174ab63d..6912ac7421 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -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"