def chunks(seq, n):
    """ Yield successive n-sized chunks from seq."""
for i in range(0, len(seq), n):
    yield seq[i:i + n]
for i, group in enumerate(dynamic_grouper(iterable, chunk_sizes)):
    for item in chunks(group, 5):
        pass
grouper with a chunk size sequence in python?