0
我想在基类(FooBase
)中做类似类属性的派生类(Foo
)。我想用Python 来做到这一点。如何在Python3中访问基类中的派生类的类属性?
class BaseFoo:
#felder = [] doesn't work
def test():
print(__class__.felder)
class Foo(BaseFoo):
felder = ['eins', 'zwei', 'yep']
if __name__ == '__main__':
Foo.test()
也许有不同的方法呢?
东西是非常错误的在这里。 'test'应该是一个*类方法*或一个*实例方法*?它至少必须接受'cls'或'self'作为论点。 – deceze