def copy_func(f, name=None):
 return types.FunctionType(six.get_function_code(f), six.get_function_globals(f), (name or f.__name__), six.get_function_defaults(f), six.get_function_closure(f))

def copy_func ( f , name = None ) : return types . FunctionType ( six . get_function_code ( f ) , six . get_function_globals ( f ) , ( name or f . __name__ ) , six . get_function_defaults ( f ) , six . get_function_closure ( f ) )
create a copy of a function .