Consider a class with a "private" method such as:
class Foo(object):
def __init__(self):
self.__method()
def __method(self):
print('42')
When I try to subclass Foo
and override method __method
, it can be seen that Foo.__method
is still called, instead of MoreFoo.__method
.
class MoreFoo(Foo):
def __method(self):
print('41')
>>> MoreFoo()
42
<__main__.MoreFoo object at 0x7fb726197d90>
What would be the way to override such a method?