fork download
  1. class parent:
  2. def __init__(self):
  3. self.a=2
  4. self.b=4
  5. def form1(self):
  6. print("calling parent from1")
  7. print('p',self.a+self.b)
  8.  
  9. class child1(parent):
  10. def __init__(self):
  11. self.a=50
  12. self.b=4
  13. def form1(self):
  14. print('bye',self.a-self.b)
  15. def callchildform1(self):
  16. print("calling parent from child1")
  17. super().form1()
  18.  
  19. class child2(parent):
  20. def __init__(self):
  21. self.a=3
  22. self.b=4
  23. def form1(self):
  24. print('hi',self.a*self.b)
  25. def callchildform1(self):
  26. print("calling parent from child2")
  27. super().form1()
  28.  
  29. class grandchild(child1,child2):
  30. def __init__(self):
  31. self.a=10
  32. self.b=4
  33. def callingparent(self):
  34. super().form1()
  35.  
  36. g=grandchild()
  37. g.callchildform1()
  38. print(grandchild.__mro__)
Success #stdin #stdout 0.02s 9200KB
stdin
Standard input is empty
stdout
calling parent from child1
hi 40
(<class '__main__.grandchild'>, <class '__main__.child1'>, <class '__main__.child2'>, <class '__main__.parent'>, <class 'object'>)