def valfilter(predicate, d, factory=dict):
    rv = factory()
    for k, v in iteritems(d):
        if predicate(v):
            rv[k] = v
    return rv
Filter items in dictionary by value
dataset/ETHPy150Open pytoolz/toolz/toolz/dicttoolz.py/valfilter