Aug-26-2019, 12:01 AM
I am trying to wrap my head around a piece of code from a text. Its a prelude to decorators, and apparently crucial to an understanding of them. But the example is rudimentary:
And func() as a function call is calling an argument?
Utterly, totally confused at this point.....
What does one *call* this?
from time import sleep, time def f(): sleep(.3) def g(): sleep(.5) def measure(func): #A t = time() func() #B print(func.__name__, 'took:', time() - t) measure(f) # f took: 0.30434322357177734 measure(g) # g took: 0.5048270225524902The problem I am having is that the named parameter and the function are not seperable. 'func' at #A appears required to define func() at #B.
And func() as a function call is calling an argument?
Utterly, totally confused at this point.....
What does one *call* this?