import itertools


def grouper(iterable, members, fillvalue=None):
    """Cut iterator into chunks."""
    args = [iter(iterable)] * members
    return itertools.zip_longest(*args, fillvalue=fillvalue)