def namespaced_function(function, global_dict, defaults=None):
    if defaults is None:
        defaults = function.__defaults__

    new_namespaced_function = types.FunctionType(
        function.__code__,
        global_dict,
        name=function.__name__,
        argdefs=defaults
    )
    new_namespaced_function.__dict__.update(function.__dict__)
    return new_namespaced_function
:see: Expression.free()
dataset/ETHPy150Open saltstack/salt/salt/utils/__init__.py/namespaced_function--crossover with--dataset/ETHPy150Open nltk/nltk/nltk/sem/logic.py/VariableBinderExpression.free