From 0c8f350f3b21d17af778eccf39aa4d23df590b6e Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Tue, 16 Feb 2010 09:31:35 -0500 Subject: [PATCH] util: use the built-in any() and all() methods if they are available --- mercurial/util.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/mercurial/util.py b/mercurial/util.py index 3858e62dbe..1943e725f2 100644 --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1343,14 +1343,17 @@ def rundetached(args, condfn): if prevhandler is not None: signal.signal(signal.SIGCHLD, prevhandler) -def any(iterable): - for i in iterable: - if i: - return True - return False +try: + any, all = any, all +except NameError: + def any(iterable): + for i in iterable: + if i: + return True + return False -def all(iterable): - for i in iterable: - if not i: - return False - return True + def all(iterable): + for i in iterable: + if not i: + return False + return True