def pass_through1(func):
def inner1(*args):
test_logs.append("pt1")
return func(*args)
return inner1
def pass_through2(func):
def inner2(*args):
test_logs.append("pt2")
return func(*args)
return inner2
@pass_through1
@pass_through2
def increment(num):
return num+1
test_logs=[]
increment(10) //gives me the answer as 11
test_logs=['pt1','pt2'] //now test_log contains after the calling the increment function
现在我怀疑增量函数是否被执行了两次?当我们将它传递给两个装饰器时。