def chunk(iterable, length):
    """Collect data into chunks.

    Arguments
    ---------
    iterable : iterable
    length   : integer
               Maximum size of each chunk to return

    Returns
    -------
    The generator produces a tuple of elements whose size is at least one but
    no more than *length*.

    If the number of elements in the iterable is not a multiple of *length*
    then the final tuple will be less than *length*.

    This function is meant to be a variant of the recipe's function grouper()
    that does not pad the last tuple with a fill-value if the number elements
    in the iterable is not a multiple of the specified length.
    """
    if length < 0:
        return ()
    iterable = iter(iterable)
    result = tuple(islice(iterable, length))
    while result:
        yield result
        result = tuple(islice(iterable, length))