You don’t need to know everything, just the concept.
Teacher’s code:
import datetime
def log(func): #1
def wrapper(*args, **kw): #2
print(f'the running function is: {func.__name__}')
print(f'the func start at {datetime.datetime.now()}') #3
return func(*args, **kw) #4
return wrapper #5
@log #6
def func1(): #7
print('this is No.1')
def func2(x, y):
z = x + y
print(f'the answer is: {z}')
func1()
func2(4, 5)
the running function is: func1
the func start at WHATEVER TIME IT IS
this is No.1
the answer is: 9