Get the function corresponding to name from obj, not the method.

def getfunc(obj, name=''):
    '''Get the function corresponding to name from obj, not the method.'''
    if name:
        obj = getattr(obj, name)
    return getattr(obj, '__func__', obj)