Call overridden method of parent class with child class object in python

后端 未结 5 852
遥遥无期
遥遥无期 2021-01-28 15:39

I have came around this question during an interview:

class Parent(object):
    def A(self):
        print \"in A\"
class Child(Parent):
    def A(self):
                


        
5条回答
  •  逝去的感伤
    2021-01-28 16:28

    Having instance C we could get its base class and call its A():
    C.__class__.__base__().A()

提交回复
热议问题