python_for_scientists icon indicating copy to clipboard operation
python_for_scientists copied to clipboard

Add true multiple inheritance

Open john-science opened this issue 4 years ago • 0 comments

Either in the second OOP lecture, or in the "More Examples" sub-lecture, we should allow for "true" multiple inheritance:

class Class1:
    def m(self):
        print("In Class1") 
        
class Class2(Class1):
    def m(self):
        print("In Class2")
  
class Class3:
    def x(self):
        print("In Class3")  
         
class Class4(Class2, Class3):
    pass   
      
c4 = Class4()
c4.m()  # prints: "In Class 2"
c4.x()  # prints: "In Class 3"

john-science avatar May 22 '21 19:05 john-science