def pass_thru(func_to_decorate):
def new_func(*args, **kwargs): #1
print("Function has been decorated. Congratulations.")
# Do whatever else you want here
return func_to_decorate(*args, **kwargs) #2
return new_func
def print_args(*args):
for arg in args:
print(arg)
a = pass_thru(print_args)
a(1,2,3)
>> Function has been decorated. Congratulations.
1
2
3
I understand that *args
is used in #1 since it is a function declaration. But why is it necessary to write *args
in #2 even if it not a function declaration?