Python 3.x 使用类变量作为classe方法的decorator参数
如何使用类变量作为类方法的装饰器参数Python 3.x 使用类变量作为classe方法的decorator参数,python-3.x,python-decorators,Python 3.x,Python Decorators,如何使用类变量作为类方法的装饰器参数 class Test: def __init__(self, value): self.value = value @decorator(self.value) # <-- problem here ;) def method(): pass 类测试: 定义初始值(自身,值): 自我价值=价值 @装饰者(自我价值)#你能描述一下你的装饰者的目的吗?或者更好——如果可以的话,发布它possible@RomanPerekhr
class Test:
def __init__(self, value):
self.value = value
@decorator(self.value) # <-- problem here ;)
def method():
pass
类测试:
定义初始值(自身,值):
自我价值=价值
@装饰者(自我价值)#你能描述一下你的装饰者的目的吗?或者更好——如果可以的话,发布它possible@RomanPerekhrest:在实际代码中,实际上有两个装饰器。一个(内部)是通用速率限制器,它利用一个模块使用redis在进程/实例之间进行同步。第二个(外部装饰器)捕获内部的RateLimit异常,随机休眠一位,然后重试。该功能与类方法功能完全无关,我不想把它弄混。问题可能重复