From: Raymond Hettinger Date: Tue, 27 Jan 2009 04:57:51 +0000 (+0000) Subject: Beautify grouper() recipe in docs. X-Git-Tag: v3.1a1~375 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=883d27607ab29afec2e524990a7b860853435074;p=python Beautify grouper() recipe in docs. --- diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 1470721465..618cf7da47 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -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" diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index b1ba8c025c..7c858eb97e 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -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"