0

我想知道是否有一种方法允许我们访问超类成员以在没有实例的情况下初始化当前类成员。

class SuperClass:
    a = 12


class ChildClass(SuperClass):
    b = SuperClass.a + 10   # This work, but not in relation way
    c = Super().a + 10      # Didn't work since not instance
    #    ^  Wanna a way kind of this. 


if __name__ == '__main__':
    print(ChildClass.a)  # OK
    print(ChildClass.b)  # OK
    print(ChildClass.c)  # Wish this would work after assign success
4

0 回答 0