I have a super class which has some class attributes like:
class Config(object):
LENGTH = 1
BREADTH = 3
Now ,I have created a subclass which will override the parent class attributes.
class Sub1(Config):
def __init__():
self.LENGTH = 200
self.BREADTH = 100
self.AREA = self.LENGTH * self.BREADTH
Now I need to write another subclass which will overwrite the values of the first sub class. Here, shall I inherit from the parent class Config or I can overwrite the values in the subclass itself and change it.
class Sub2(Sub1):
self.AREA_UPDATED = self.AREA + 20
This is not working.
class Sub2(Config):
self.LENGTH = "efg"
self.BREADTH = 100
self.AREA = self.LENGTH * self.BREADTH
self.AREA_UPDATED = self.AREA + 20
This works. What am I doing conceptually wrong, is it that the parent class can be inherited only? Kindly advice.
Thanks