def function( receiver ):
    """Get function-like callable object for given receiver

    returns (function_or_method, codeObject, fromMethod)

    If fromMethod is true, then the callable already
    has its first argument bound
    """
    if hasattr(receiver, '__call__'):
        # Reassign receiver to the actual method that will be called.
        if hasattr( receiver.__call__, im_func) or hasattr( receiver.__call__, im_code):
            receiver = receiver.__call__
    if hasattr( receiver, im_func ):
        # an instance-method...
        return receiver, getattr(getattr(receiver, im_func), func_code), 1
    elif not hasattr( receiver, func_code):
        raise ValueError('unknown reciever type %s %s'%(receiver, type(receiver)))
    return receiver, getattr(receiver,func_code), 0
Get function-like callable object for given receiver

    returns (function_or_method, codeObject, fromMethod)

    If fromMethod is true, then the callable already
    has its first argument bound
    
stackoverflow/venv/lib/python3.6/site-packages/pydispatch/robustapply.py