def consume(iter, N=None):
    '''Consumes N items from iter.  If N is None (or not given), consumes all.
    '''
    i = iter
    if N is not None:
        i = islice(iter, N)

    for x in i:
        pass
Consumes N items from iter.  If N is None (or not given), consumes all.