def get_function_name(f):
    """
    Get name for either a function or a functools.partial.
    """
    try:
        return f.__name__
    except AttributeError:
        pass

    # this works for functools.partial objects
    try:
        return f.func.__name__
    except AttributeError:
        pass

    return type(f).__name__