def countmatching(iterable, *predicates):
    v = [0] * len(predicates)
for e in iterable:
    for i, p in enumerate(predicates):
        if p(e):
            v[i] += 1
return tuple(v)
Most pythonic way of counting matching elements in something iterable