|
From: <nev...@us...> - 2010-03-01 04:47:05
|
details: http://hg.localdomain.org/vmm/rev/7e9874a50d92 changeset: 224:7e9874a50d92 user: Pascal Volk date: Mon Mar 01 04:46:46 2010 +0000 description: VMM/pycompat: added function any() for Python 2.4 diffstat: VirtualMailManager/pycompat.py | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diffs (22 lines): 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 |