Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 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 | e6dc44147234 |
children | cb681cc59a8d 1b45468d3deb |
comparison
equal
deleted
inserted
replaced
10486:6b354a763617 | 10487:7a6b5f85c3ab |
---|---|
1341 return pid | 1341 return pid |
1342 finally: | 1342 finally: |
1343 if prevhandler is not None: | 1343 if prevhandler is not None: |
1344 signal.signal(signal.SIGCHLD, prevhandler) | 1344 signal.signal(signal.SIGCHLD, prevhandler) |
1345 | 1345 |
1346 def any(iterable): | 1346 try: |
1347 for i in iterable: | 1347 any, all = any, all |
1348 if i: | 1348 except NameError: |
1349 return True | 1349 def any(iterable): |
1350 return False | 1350 for i in iterable: |
1351 | 1351 if i: |
1352 def all(iterable): | 1352 return True |
1353 for i in iterable: | 1353 return False |
1354 if not i: | 1354 |
1355 return False | 1355 def all(iterable): |
1356 return True | 1356 for i in iterable: |
1357 if not i: | |
1358 return False | |
1359 return True |