I have this decorator which takes one argument by itself before it decorates a provided function.
That decorator is then used to decorate a class method. Let's say we have the following code:
from somewhere import dec
class Something:
def __init__(self, variable = 5):
self.variable = variable
@dec(need_to_access_instance_self_variable)
def some_method(self, blahblah):
# does something
pass
Everything works like a charm, except I'd like to pass self.variable
as an argument to the decorator—and nothing hasn't worked for me so far.
Is this even possible? I cannot seem to figure out the scoping. Any ideas how would that be achievable?
Thank you!