I am new to Python decorators.I am able to run the decorator without passing any arguments. And is working fine.
I am interested in passing to_decorator
value to the decorator function as show below.
Is this possible?
def test(self, *args):
return "from test"
def decorate(function):
def wrap_function(*args, **kwargs):
print(*args)
return function(*args, **kwargs)
return wrap_function
class Sample():
@decorate
def message(*args, **kwargs):
to_decorator = test(*args)
print(to_decorator)
Sample.message("Hello123")
Thanks in advance.