VirtualMailManager/pycompat/__init__.py
branchv0.7.x
changeset 637 ca6621caff2f
parent 636 27334cfc0c90
child 638 0de0b9e75c9f
equal deleted inserted replaced
636:27334cfc0c90 637:ca6621caff2f
     1 # -*- coding: UTF-8 -*-
       
     2 # Copyright (c) 2010 - 2012, 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