def function_named(fn, name):
    """Return a function with a given __name__.

    Will assign to __name__ and return the original function if possible on
    the Python implementation, otherwise a new function will be constructed.

    """
    try:
        fn.__name__ = name
    except __HOLE__:
        fn = new.function(fn.func_code, fn.func_globals, name,
                          fn.func_defaults, fn.func_closure)
    return fn
dataset/ETHPy150Open ralfonso/theory/theory/model/mpdutil.py/function_named