# HG changeset patch # User Pascal Volk # Date 1267418806 0 # Node ID 7e9874a50d92a79c1f2951929ad7d0d0b5ae721d # Parent 5c7b7cbb01cd859e7a95265d3747a91f812fdfe1 VMM/pycompat: added function any() for Python 2.4 diff -r 5c7b7cbb01cd -r 7e9874a50d92 VirtualMailManager/pycompat.py --- a/VirtualMailManager/pycompat.py Mon Mar 01 02:31:03 2010 +0000 +++ b/VirtualMailManager/pycompat.py Mon Mar 01 04:46:46 2010 +0000 @@ -21,3 +21,18 @@ if not element: return False return True + + +# http://docs.python.org/library/functions.html#any +try: + any = any +except NameError: + def any(iterable): + """Return True if any element of the *iterable* is true. If the + iterable is empty, return False. + + """ + for element in iterable: + if element: + return True + return False