1 2 3 4 5 6 7 8 9 10 11 12 13 14
>>> import itertools >>> def anyTrue(predicate, iterable): ... return True in itertools.imap(predicate, iterable) >>> def is3(i): ... print "i=%s" % i ... return i == 3 >>> anyTrue(is3, range(10)) i=0 i=1 i=2 i=3 True