草庐IT

ABSTRACT

全部标签

关于继承:Python NotImplementedError for instance attributes

PythonNotImplementedErrorforinstanceattributes如何将实例属性标记为未在基类中实现?(与讨论将类属性标记为未实现的问题不同,但也许我没有正确理解基类......)例如我想要类似的东西123456789101112131415161718classBase():  def__init__(self):    self.x=NotImplementedclassGoodSub(Base):  def__init__(self,x):    super().__init__()    self.x=x#goodclassBadSub(Base):  def

关于继承:Python NotImplementedError for instance attributes

PythonNotImplementedErrorforinstanceattributes如何将实例属性标记为未在基类中实现?(与讨论将类属性标记为未实现的问题不同,但也许我没有正确理解基类......)例如我想要类似的东西123456789101112131415161718classBase():  def__init__(self):    self.x=NotImplementedclassGoodSub(Base):  def__init__(self,x):    super().__init__()    self.x=x#goodclassBadSub(Base):  def