Non-short-circuit variant of any/all

suggest change

reduce does not stop before the iterable has been completely iterated, so it can be used as a non-short-circuit any() or all(). For bool values, operator.and_ and operator.or_ return bool:

import operator
from functools import reduce
# non short-circuit "all"
reduce(operator.and_, [False, True, True, True]) # = False

# non short-circuit "any"
reduce(operator.or_, [True, False, False, False]) # = True

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents