Is there a way to combine two decorators into one new decorator in python?
I realize I can just apply multiple decorators to a function, but I was curious as to whet
If the decorators don't take additional arguments, you could use
def compose(f, g): return lambda x: f(g(x)) combined_decorator = compose(decorator1, decorator2)
Now
@combined_decorator def f(): pass
will be equivalent to
@decorator1 @decorator2 def f(): pass