任何非短路變體

reduce 在完全迭代完 iterable 之前不會終止迭代,因此它可用於建立非短路 any()all() 函式:

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

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