def alias_function(fun, name, doc=None):
 alias_fun = types.FunctionType(fun.__code__, fun.__globals__, name, fun.__defaults__, fun.__closure__)
 alias_fun.__dict__.update(fun.__dict__)
 if (doc and isinstance(doc, six.string_types)):
  alias_fun.__doc__ = doc
 else:
  orig_name = fun.__name__
  alias_msg = '\nThis function is an alias of ``{0}``.\n'.format(orig_name)
  alias_fun.__doc__ = (alias_msg + fun.__doc__)
 return alias_fun

def alias_function ( fun , name , doc = None ) : alias_fun = types . FunctionType ( fun . __code__ , fun . __globals__ , name , fun . __defaults__ , fun . __closure__ ) alias_fun . __dict__ . update ( fun . __dict__ ) if ( doc and isinstance ( doc , six . string_types ) ) : alias_fun . __doc__ = doc else : orig_name = fun . __name__ alias_msg = '\nThis function is an alias of ``{0}``.\n' . format ( orig_name ) alias_fun . __doc__ = ( alias_msg + fun . __doc__ ) return alias_fun
copy a function .