def chunk(size, iterable, pad=[None]):
    """
    Yields the iterable in chunks of the given size

    @params size     The size of the chunks
            iterable The iterable to chunk
    @yields          The next chunk
    """
    for i in range(0, len(iterable), size):
        chunk = iterable[i:i + size]
        if len(chunk) < size:
            chunk += pad * (size - len(chunk))
        yield chunk
