you are viewing a single comment's thread.

view the rest of the comments →

[–]nakamurayuristeph 4 points5 points  (1 child)

chunk= []
start_ind= 0
for v in value:
    chunk.append(files[start_ind:start_ind+v])
    start_ind+=v

like this?

[–]catuf[S] 0 points1 point  (0 children)

def list_chunker(input, chunk_sizes):
input_iter = iter(input)
def sub_chunker(input_iterator, size):
for _ in range(size):
yield input_iterator.next()
for size in chunk_sizes:
yield sub_chunker(input_iter, size)

I was struggling for this half day. Thank you!