def print_args(func):
def wr(*args, **kwargs):
func(*args, **kwargs)
print('*Args:', *args)
print('**Kwargs:', **kwargs)
return wr
@print_args
def func_with_args(a,b,c):
print('something')
print(a,b,c)
func_with_args(1,2, dog='sharik')
Вывод:
Traceback (most recent call last):
File "C:\Users\_\Documents\python\test.py", line 20, in
func_with_args(1,2, dog='sharik')
File "C:\Users\_\Documents\python\test.py", line 7, in wr
func(*args, **kwargs)
TypeError: func_with_args() got an unexpected keyword argument 'dog'
[Finished in 0.1s with exit code 1]
ПОчему?)) Не хочет работать с параметрами **kwargs совсем(