I was just perusing the Built-in Functions of Python 3.2 (<<a href="http://docs.python.org/py3k/library/functions.html">http://docs.python.org/py3k/library/functions.html</a>>) and was wondering where would one ever use any() or all(). <br>
<br>all(iterable)<br>Return True if all elements of the iterable are true (or if the iterable is empty). Equivalent to:<br><br>def all(iterable):<br> for element in iterable:<br> if not element:<br> return False<br>
return True<br><br>any(iterable)<br>Return True if any element of the iterable is true. If the iterable is empty, return False. Equivalent to:<br><br>def any(iterable):<br> for element in iterable:<br> if element:<br>
return True<br> return False<br><br>Given a = [0, 1, 2, 3],<br><br>>>> all(a)<br>False<br>>>> any(a)<br>True<br><br>But so what? Could I get some better examples?<br><br>And why<br><font face="courier new, monospace">>>> all([])<br>
True<br>>>> any([])<br>False</font><br><br>Thanks,<br><br>Dick Moores