所以我有一个类,我将其用作本地命名空间。我在类中有一些静态函数,但它们无法访问类范围变量。为什么是这样?
class Foo:
foo_string = "I am a foo"
@staticmethod
def foo():
print foo_string
>>> Foo.foo()
[Stack Trace]
NameError: global name 'foo_string' is not defined
有什么想法吗?