从类变量引用静态方法 [英] referencing static methods from class variable
本文介绍了从类变量引用静态方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道有这样的情况是不可避免的,但不知何故我有:
I know it's wired to have such a case but somehow I have it:
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 }
这篇关于从类变量引用静态方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文