def chunked(seq, n):
    seq = iter(seq)
    while 1:
        rv = list(itertools.islice(seq, 0, n))
        if not rv:
            break
        yield rv
Yield successive n-sized chunks from seq.
dataset/ETHPy150Open mozilla/addons-server/src/olympia/amo/utils.py/chunked