Python equivalent of LINQ All function? Python equivalent of LINQ All function? python python

Python equivalent of LINQ All function?


all_match = all(test(x) for x in stuff)

This short-circuits and doesn't require stuff to be a list -- anything iterable will work -- so has several nice features.

There's also the analogous

any_match = any(test(x) for x in stuff)