Example #1
0
def callable_wrapper(func): #{{{
    if not iscallable(func):
        raise TypeError('Argument is not callable')
    def callwrapper(*args, **kwargs): #{{{
        return func(*args, **kwargs)
    # End def #}}}
    return callwrapper
Example #2
0
def needs_wrapping(obj): #{{{
    if not iscallable(obj):
        return False
    elif _ism(obj) or _isf(obj) or isclass(obj):
#    elif any(f(obj) for f in (_ism, _isf, isclassmethod, isstaticmethod)):
        return False
    elif hasattr(obj, '__call__') and _ism(obj.__call__):
        return False
    else:
        return True
Example #3
0
def callableobj(obj): #{{{
    if not iscallable(obj):
        return None
    if _ism(obj) or _isf(obj) or isclass(obj):
#    if any(f(obj) for f in (_ism, _isf, isclassmethod, isstaticmethod)):
        return obj
    elif hasattr(obj, '__call__') and _ism(obj.__call__):
        return obj.__call__
    else:
        obj = callable_wrapper(obj)
    return obj