def addClassMethod(classInstance, func, methName=None):
    """adds function as a new class method to an existing class.
       function should have self as first argument
    """
    name = methName or func.__name__
    setattr(classInstance, name, classmethod(func))
adds function as a new class method to an existing class.
       function should have self as first argument
    
recipes/Python/201294_Dynamic_Classes/recipe-201294.py