Alter recipe to show how to call izip_longest() with

both a keyword argument and star arguments.
This commit is contained in:
Raymond Hettinger 2008-07-31 01:19:50 +00:00
parent 246daedd11
commit f080e6d7e0
2 changed files with 2 additions and 4 deletions

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

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