Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 使用类变量作为classe方法的decorator参数_Python 3.x_Python Decorators - Fatal编程技术网

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异常,随机休眠一位,然后重试。该功能与类方法功能完全无关,我不想把它弄混。问题可能重复