for_some(), for_all()?
Michael Hoffman
m.h.3.9.1.without.dots.at.cam.ac.uk at example.com
Thu Sep 23 06:55:53 EDT 2004
Raymond Hettinger wrote:
> For pure speed, the following is faster and gives short-circuit behavior:
>
>>>>from itertools import ifilter
>>>>def any(seq, pred=None):
>
> ... for elem in ifilter(pred, seq):
> ... return True
> ... return False
Nice! I've always found the itertools examples exceptionally useful. Is
there a reason why they aren't in the standard library? I find myself
copying and pasting the snippets all the time.
--
Michael Hoffman
More information about the Python-list
mailing list