def copyfunc(f, name=None):
 try:
  return types.FunctionType(f.func_code, f.func_globals, (name or f.__name__), f.func_defaults, f.func_closure)
 except AttributeError:
  return types.FunctionType(f.__code__, f.__globals__, (name or f.__name__), f.__defaults__, f.__closure__)

def copyfunc ( f , name = None ) : try : return types . FunctionType ( f . func_code , f . func_globals , ( name or f . __name__ ) , f . func_defaults , f . func_closure ) except AttributeError : return types . FunctionType ( f . __code__ , f . __globals__ , ( name or f . __name__ ) , f . __defaults__ , f . __closure__ )
returns a deepcopy of a function .