How do I mark an instance attribute as not implemented in a base class? (Distinct from this question which discusses marking class attributes as not implemented, but perhaps I'm not understanding base classes correctly...)
e.g. I want something like
class Base():
def __init__(self):
self.x = NotImplemented
class GoodSub(Base):
def __init__(self, x):
super().__init__()
self.x = x #good
class BadSub(Base):
def __init__(self):
super().__init__()
#forgot to set self.x
good = GoodSub(5)
bad = BadSub(-1)
good.x #returns 5
bad.x #throws error because x not implemented
Or, is there a better way to enforce all subclasses of Base
to set the self.x
attribute upon init?
Edit: link to related question