def return_fq_name(func, klass=None):
    """
    Resolve a fully qualified name for a function
    or method
    """
    func_name = getattr(func, 'func_name', None)
    func_module = getattr(func, '__module__', None)
    if klass:
        name = '%s.%s.%s' % (klass.__module__, klass.__name__, 'PyCallable')
    elif func_name:
        name = '%s.%s' % (func_module, func_name)
    else:
        name = str(func)
        if name.startswith('<') and name.endswith('>'):
            name = name[1:-1]
    return name
