0
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
making C().grok()
the same returns to me 'a'
, which I think is correct since the methods of A
takes precedence over those of B
, but why when I call the class methods C.foo()
get back to me 'A'
and 'B'
? You shouldn’t just return 'A'
, since in method solving 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 the class A
he continues to search? It has something to do with the method being class, if yes why?
I tested your code here and only returned A.
– user110265
What did you intend to do with
super().foo()
in the method itselffoo
?– Woss