Mercurial > hg
changeset 10487:7a6b5f85c3ab stable
util: use the built-in any() and all() methods if they are available
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Tue, 16 Feb 2010 09:31:35 -0500 |
parents | 6b354a763617 |
children | 3232dba5d521 |
files | mercurial/util.py |
diffstat | 1 files changed, 13 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Mon Feb 15 21:18:16 2010 -0600 +++ b/mercurial/util.py Tue Feb 16 09:31:35 2010 -0500 @@ -1343,14 +1343,17 @@ 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