[Solved] Override method of class in another file


Would overriding func1 work?

class Class(file1.Class2):
    def func1(self):
        print "Class3.func1"

c = Class3()
c.func2()

Since func2 is not defined in Class3, Class2.func2 is called. However, in the body of that function, self is still an instance of Class3, so self.func1() calls Class3.func1, not Class1.func1. That is different from

d = Class2()
d.func2()

where self in Class2.func2 is an instance of Class2. Class2 does not define func1, so Class1.func1 is called.

1

solved Override method of class in another file