Issue 1432437: itertools.any and itertools.all (original) (raw)

Issue1432437

Created on 2006-02-15 20:26 by paulcannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg54722 - (view) Author: paul cannon (paulcannon) Date: 2006-02-15 20:26
Just a couple very simple "shortcutting" functions that I find myself needing quite frequently. "reduce(operator.or_, foo, False)" is all right, but potentially does a lot more work. def any(i): """Returns true if any element from i is true.""" for element in i: if i: return True return False all() would also be nice: def all(i): """Returns true if all elements from i are true.""" for element in i: if not i: return False return True ..although it /could/ simply be built on any() as "not any(imap(operator.not_, i))".
msg54723 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-15 20:44
Logged In: YES user_id=1188172 These two happen to become builtins in 2.5.
msg54724 - (view) Author: paul cannon (paulcannon) Date: 2006-02-15 21:17
Logged In: YES user_id=222090 I love you people.
History
Date User Action Args
2022-04-11 14:56:15 admin set github: 42907
2006-02-15 20:26:42 paulcannon create