def batches(iterable, size):
    """
    Take an iterator and yield its contents in groups of `size` items.
    """
    sourceiter = iter(iterable)
    while True:
        batchiter = islice(sourceiter, size)
        yield chain([next(batchiter)], batchiter)
def batches(iterable, size):
    
    sourceiter = iter(iterable)
    while True:
        batchiter = islice(sourceiter, size)
        yield chain([next(batchiter)], batchiter)
def batches ( iterable , size ) : sourceiter = iter ( iterable ) while True : batchiter = islice ( sourceiter , size ) yield chain ( [ next ( batchiter ) ] , batchiter )
Take an iterator and yield its contents in groups of `size` items.
Take an iterator and yield its contents in groups of size items .