Beautify grouper() recipe in docs.

This commit is contained in:
Raymond Hettinger 2009-01-27 04:57:51 +00:00
parent 749761e1a8
commit 883d27607a
2 changed files with 2 additions and 2 deletions

View 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"

View 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"