def determine_name(func):
    if hasattr(func, '__name__'):
        return func.__name__
    elif hasattr(func, '__class__'):
        return func.__class__.__name__

    # This shouldn't be possible, but blow up if so.
    raise AttributeError("Provided callable '{}' has no name.".format(
        func
    ))
Given a function, returns the name of the function.
dataset/ETHPy150Open toastdriven/alligator/alligator/utils.py/determine_name