def bucket(it, size):
    """
    >>> [tuple(lis) for lis in bucket([1, 2, 3, 4, 5, 6, 7], 3)]
    [(1, 2, 3), (4, 5, 6), (7,)]
    """
    assert size > 0
    i = 0
    stock = []
    for el in it:
        stock.append(el)
        i += 1
        if i == size:
            yield stock
            stock = []
            i = 0
    if stock:
        yield stock
