File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -914,14 +914,15 @@ which incur interpreter overhead.
914
914
# grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError
915
915
# grouper('ABCDEFG', 3, incomplete='ignore') --> ABC DEF
916
916
args = [iter(iterable)] * n
917
- if incomplete == 'fill':
918
- return zip_longest(*args, fillvalue=fillvalue)
919
- elif incomplete == 'strict':
920
- return zip(*args, strict=True)
921
- elif incomplete == 'ignore':
922
- return zip(*args)
923
- else:
924
- raise ValueError('Expected fill, strict, or ignore')
917
+ match incomplete:
918
+ case 'fill':
919
+ return zip_longest(*args, fillvalue=fillvalue)
920
+ case 'strict':
921
+ return zip(*args, strict=True)
922
+ case 'ignore':
923
+ return zip(*args)
924
+ case _:
925
+ raise ValueError('Expected fill, strict, or ignore')
925
926
926
927
def sliding_window(iterable, n):
927
928
# sliding_window('ABCDEFG', 4) --> ABCD BCDE CDEF DEFG
You can’t perform that action at this time.
0 commit comments