mirror of
https://github.com/python/cpython.git
synced 2024-11-28 04:15:11 +08:00
Issue 17862: Improve the signature of itertools grouper() recipe.
Putting *n* after the *iterable* matches the signature of other itertools and recipes. Also, it reads better. Suggested by Ezio Melotti.
This commit is contained in:
parent
5b1ab24751
commit
44571daf0e
@ -705,9 +705,9 @@ which incur interpreter overhead.
|
||||
next(b, None)
|
||||
return zip(a, b)
|
||||
|
||||
def grouper(n, iterable, fillvalue=None):
|
||||
def grouper(iterable, n, fillvalue=None):
|
||||
"Collect data into fixed-length chunks or blocks"
|
||||
# grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
|
||||
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
|
||||
args = [iter(iterable)] * n
|
||||
return zip_longest(*args, fillvalue=fillvalue)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user