python inherit B from A code example
Example 1: python subcalss
class SubClass(SuperClass):
super().__init__(self,atr1,atr2)
super().SomeMethod(self)
def OtherMethod(self,atr3):
pass #Do Things
def OverwrittenMethod(self,atr1,atr4):
pass #If you create a method with the same name as on in the superclass
#The one in the subclass will overwite the original methos
Example 2: how to inherit a class in python
class Bird():
def eat(self):
print ("eating")
class Sparrow(Bird):
def sound(self):
print ("ChiChi!")
birdobj = Sparrow()
birdobj.eat()
birdobj.sound()