python-访问超类属性
您好,我想在python中实现以下功能,但是我不知道用什么替换行python-访问超类属性,python,inheritance,Python,Inheritance,您好,我想在python中实现以下功能,但是我不知道用什么替换行super.a=b: class Super: def __init__(self): self.a = 1 class Sub(Super): def method(self, b): super.a = b Sub是Super,即Sub的所有实例都可以像Super的实例一样处理。在您的情况下,这意味着您只需设置self.a=b
super.a=b
:
class Super:
def __init__(self):
self.a = 1
class Sub(Super):
def method(self, b):
super.a = b
Sub
是Super
,即Sub
的所有实例都可以像Super
的实例一样处理。在您的情况下,这意味着您只需设置self.a=b