Python public recipes
Split a list into multiple sublists.
Example ot use
sublists = chunks(mylist, 3)
will return a split of the initial mylist
into lists of at most 3 elements.
def chunks(lst, n):
"""Yield successive n-sized chunks from lst."""
for i in range(0, len(lst), n):
yield lst[i:i + n]