def partition(pred, *args):
    """Generate a sequence of pairs of the form (p, v) where p is
    either a true value or False and v is one of the values of the
    input sequence; those values for which pred returns true receive p
    = True; others receive p = False.  The predicate is called with
    one element of the sequence, and any args provided.
    """
    def partitioner(input):
        for elt in input:
            p = pred(elt, *args)
            if p:
                yield (p, elt)
            else:
                yield (False, elt)

    return partitioner