我知道有这样的情况是有线的,但不知何故我有:
class foo
#static method
@staticmethod
def test():
pass
# class variable
c = {'name' : <i want to reference test method here.>}
它的出路是什么?
仅作记录:
我认为这应该被视为 Python 最糟糕的做法。如果曾经使用静态方法并不是真正的 pythoish 方式......
最佳答案
class Foo:
# static method
@staticmethod
def test():
pass
# class variable
c = {'name' : test }
关于python - 从类变量引用静态方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2194185/