def filter_values(pred, d):
    """ Returns a new dict with only those k, v pairs where pred(v) holds.

    >>> D = {'a': 1, 'b': 2, 'c': 3}
    >>> odd = lambda x: x % 2 != 0
    >>> filter_values(odd, D)
    {'a': 1, 'c': 3}
    """
    return dict((k, v) for k, v in d.iteritems() if pred(v))