0
我得到了Python装饰器的基本原理,我喜欢它的语法。但是,他们似乎对你能做的事情有一点限制。作为参数的多个函数的Python装饰器?
有没有一种优雅的方式去处理多个函数,如下面的参数?
def parent_fn(child_fn1, child_fn2):
def wrapper():
print('stuff is happening here')
child_fn1()
print('other stuff is happening here')
child_fn2()
return wrapper
@parent_fn
def decorated():
print('child_fn1 stuff here')
decorated()
我在哪里可以放入child_fn2代码?我尝试过的几个想法似乎从装饰者的简单和优雅中消失。