

def chunk_iter(iterable, n):
    "Yields an iterator in chunks\n\n    For example you can do\n\n    for a, b in chunk_iter([1, 2, 3, 4, 5, 6], 2):\n        print('{0} {1}'.format(a, b))\n\n    # Prints\n    # 1 2\n    # 3 4\n    # 5 6\n\n    Args:\n        iterable - Some iterable\n        n - Chunk size (must be greater than 0)\n    "
    assert (n > 0)
    iterable = iter(iterable)
    chunk = tuple(itertools.islice(iterable, n))
    while chunk:
        (yield chunk)
        chunk = tuple(itertools.islice(iterable, n))

dataset/ETHPy150Open Yelp/git-code-debt/git_code_debt/util/iter.py chunk_iter/original