builtin functions for and and or?
Brian Beck
exogen at gmail.com
Sun Feb 13 16:43:29 EST 2005
Brian Beck wrote:
> def all(seq, pred=bool):
> "Returns True if pred(x) is True for every element in the iterable"
> for elem in ifilterfalse(pred, seq):
> return False
> return True
>
> def any(seq, pred=bool):
> "Returns True if pred(x) is True for at least one element in the
> iterable"
> for elem in ifilter(pred, seq):
> return True
> return False
I should probably note, you'll have to
from itertools import ifilter, ifilterfalse
to use these.
--
Brian Beck
Adventurer of the First Order
More information about the Python-list
mailing list