0
def logging_decorator(function):
    def wrapper(*args, **kwargs):
        print(f'This is {function.__name__}')
        output = function(*args, **kwargs)
    return wrapper


@logging_decorator
def a_function(a, b, c):
    print(f'This is the Function name {a_function.__name__}')
    return a * b * c

object = a_function(3, 4, 5)

Been playing around with python decorators and I don't understand the following:

Why does

print(f'This is the Function name {a_function.__name__}')

output 'This is the Function name wrapper'? Shouldn't the output be 'This is the Function name a_function' instead?

Paul Ged
  • 33
  • 5

0 Answers0