Let's say I have something like this:
# -*- coding: utf-8 -*-
class Base(object):
@classmethod
def foo(cls):
pass
def grok(self):
pass
class A(Base):
@classmethod
def foo(cls):
print('A')
super().foo()
def grok(self):
print('a')
class B(Base):
@classmethod
def foo(cls):
print('B')
super().foo()
def grok(self):
print('b')
class C(A, B):
pass
When I call the method grok
doing C().grok()
it returns me 'a'
, which I think is correct since A
methods takes precedence over B
methods, but why when I call the methods of class C.foo()
returns me 'A'
and 'B'
? Should not I just return 'A'
, since in solving methods in Python it looks for the methods in the class if it does not find search in its base class? Why even after finding the method in class A
does it continue to search? It has something to do with the method being class, if so why?