I want to use self.something as a parameter of decorator. like this:
def synchronized(lock):
def decorator(func):
def wrapper(*args, **kwargs):
with lock:
func(*args, **kwargs)
return wrapper
return decorator
class A:
def __init__(self):
self.lock = Lock()
@synchronized(self.lock)
def test(self):
pass
but I can't use self in this situation. plz help me.