0
我該如何做到這一點?Python從父級靜態方法調用子靜態變量
class Parent:
Foo = 'Parent food'
@staticmethod
def bar():
# want to print whatever the child's Foo is
class Child(Parent):
Foo = 'Child foo'
# This should print "Child foo"
Child.bar()
你想要一個_classmethod_一個
classmethod
,不_staticmethod_。靜態方法的定義是無狀態的。 –