How do I override a parent class's functions in python?
问题 I have a private method def __pickSide(self): in a parent class that I would like to override in the child class. However, the child class still calls the inherited def __pickSide(self): . How can I override the function? The child class's function name is exactly the same as the parent's function name. 回答1: Let's look at the easiest example: from dis import dis class A(object): def __pick(self): print "1" def doitinA(self): self.__pick() class B(A): def __pick(self): print "2" def doitinB