#NEWLINE# def namespaced_function( function , global_dict , defaults = None ) : #NEWLINE# #INDENT# '\n    Redefine (clone) a function under a different globals() namespace scope\n    ' #NEWLINE# if ( defaults is None ) : #NEWLINE# #INDENT# defaults = function . __defaults__ #NEWLINE# #UNINDENT# new_namespaced_function = types . FunctionType ( function . __code__ , global_dict , name = function . __name__ , argdefs = defaults ) #NEWLINE# new_namespaced_function . __dict__ . update ( function . __dict__ ) #NEWLINE# return new_namespaced_function