Friday, January 14, 2022

[python][Example] python get parent class function

class A:
    def getA(self):
        return 1

class B:
    a = A()
    def getB(self):
        return 2 * self.a.getA()

class C(B):
    def getC(self):
        return self.a.getA()

c = C()
print(c.getC())

Reference 

https://www.geeksforgeeks.org/python-call-parent-class-method/

No comments :

Post a Comment