From d201b0cf3a6d2221a44ea90795d2956e6e255169 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 3 May 2009 20:34:48 -0400 Subject: [PATCH] Add implementations of any() and all(). --- src/__init__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/__init__.py b/src/__init__.py index df1f203..7054e3a 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -621,6 +621,25 @@ def product(iterable): +try: + all = __builtins__.all + any = __builtins__.any +except AttributeError: + def all(iterable): + for i in iterable: + if not i: + return False + return True + + def any(iterable): + for i in iterable: + if i: + return True + return False + + + + def argmin_f(list, f = lambda x: x): # deprecated -- the function has become unnecessary because of # generator expressions -- GitLab