On Jun 8, 2:16 pm, danieldelay <danielde...@gmail.com> wrote: > def firsttrue(iterable): > for element in iterable: > if element: > return element > return None > > This function "firsttrue( )" could probably be used anywhere "any( )" is > used, but with the ability to retrieve the first element where > bool(element) is True, which may be sometimes usefull.
FWIW, it's not hard to roll your own fast itertools variants of any() and all(): next(ifilter(None, d), False) # first true, else False next(ifilterfalse(None, d), True) # first false, else True Raymond -- http://mail.python.org/mailman/listinfo/python-list