First page Back Continue Last page Overview Graphics

Manually Fixing the Problem

We can save the original attributes of the function f, if we assign them inside of the decorator.

def greeting(func):

def function_wrapper(x):

""" function_wrapper of greeting """

print("Hi, " + func.__name__ + " returns:")

return func(x)

function_wrapper.__name__ = func.__name__

function_wrapper.__doc__ = func.__doc__

function_wrapper.__module__ = func.__module__

return function_wrapper