W
W
w0lkolak2020-05-21 23:19:36
Python
w0lkolak, 2020-05-21 23:19:36

How does the wrapper even get the arguments of the wrapped function?

I intuitively thought that we send a function with variables inside to the decorator, and referring to the wrapper , we just run it. Why does it take arguments from func1 if they are kind of "foreign" and still part of the call to func1 ? How to fit the work of the wrapper in your head?

def dec(func1):
   def wrapper(*arg):
       func1(*arg)
   return wrapper

@dec
def func1(a,b,c):
      pass

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2020-05-21
@w0lkolak

https://habr.com/ru/post/141411/
https://habr.com/ru/post/141501/
rub the
wrapper through the objects until you are completely satisfied

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question