def mergeFunctionMetadata(f, g):
"""
Overwrite C{g}'s docstring and name with values from C{f}. Update
C{g}'s instance dictionary with C{f}'s.
"""
try:
g.__doc__ = f.__doc__
except (TypeError, AttributeError):
pass
try:
g.__dict__.update(f.__dict__)
except (TypeError, AttributeError):
pass
try:
g.__name__ = f.__name__
except TypeError:
try:
g = new.function(
g.func_code, g.func_globals,
f.__name__, inspect.getargspec(g)[-1],
g.func_closure)
except TypeError:
pass
return g
评论列表
文章目录