VirtualMailManager/pycompat/__init__.py
changeset 760 b678a1c43027
parent 748 659c4476c57c
child 761 e4e656f19771
equal deleted inserted replaced
748:659c4476c57c 760:b678a1c43027
     1 # -*- coding: UTF-8 -*-
       
     2 # Copyright (c) 2010 - 2014, Pascal Volk
       
     3 # See COPYING for distribution information.
       
     4 
       
     5 """
       
     6     VirtualMailManager.pycompat
       
     7 
       
     8     VirtualMailManager's compatibility stuff for Python 2.4
       
     9 """
       
    10 
       
    11 # http://docs.python.org/library/functions.html#all
       
    12 try:
       
    13     all = all
       
    14 except NameError:
       
    15     def all(iterable):
       
    16         """Return True if all elements of the *iterable* are true
       
    17         (or if the iterable is empty).
       
    18 
       
    19         """
       
    20         for element in iterable:
       
    21             if not element:
       
    22                 return False
       
    23         return True
       
    24 
       
    25 
       
    26 # http://docs.python.org/library/functions.html#any
       
    27 try:
       
    28     any = any
       
    29 except NameError:
       
    30     def any(iterable):
       
    31         """Return True if any element of the *iterable* is true.  If the
       
    32         iterable is empty, return False.
       
    33 
       
    34         """
       
    35         for element in iterable:
       
    36             if element:
       
    37                 return True
       
    38         return False