Let's say I have a function that is decorated by multiple decorators.
# file.py
@deco1
@deco2('param')
@deco3(
'multiple',
'long',
'params'
)
@deco4('multiple', 'params')
def foo():
"""Function foo
"""
pass
Let's just say it looks very dirty. VERY dirty.
I want to be able to do something like this.
# another_file.py
@deco1
@deco2('param')
@deco3(
'multiple',
'long',
'params'
)
@deco4('multiple', 'params')
def all_decorators_for_foo():
...
# file.py
from another_file import all_decorators_for_foo
@all_decorators_for_foo
def foo():
"""Yay!
"""
...
Just for the sake of context, the multiple decorators are swagger documentation decorators for sanic framework.
Is it possible in python to achieve something similar to this?
This question does not in any way answer my question. Decorators can anyway be stacked together and used. I want some sort of decorator that can be used in place of all the stacked decorators.