def chunkiter(iterable, chunksize):
    """break an iterable into chunks and yield those chunks as lists
    until there's nothing left to yeild.
    """
    iterator = iter(iterable)
    for chunk in iter(lambda: list(itertools.islice(iterator, chunksize)), []):
        yield chunk
break an iterable into chunks and yield those chunks as lists
    until there's nothing left to yeild.