def split_every ( iterable , n ) : # TODO: Remove this, or make it return a generator. i = iter ( iterable ) piece = list ( islice ( i , n ) ) while piece : yield piece piece = list ( islice ( i , n ) )
python grab every n elements
A generator of n - length chunks of an input iterable
def split_every(iterable, n):  # TODO: Remove this, or make it return a generator.
    """
    A generator of n-length chunks of an input iterable
    """
    i = iter(iterable)
    piece = list(islice(i, n))
    while piece:
        yield piece
        piece = list(islice(i, n))