W
W
Web__Nikita032019-03-08 19:06:50
Python
Web__Nikita03, 2019-03-08 19:06:50

How are classes inherited and how does mro work?

Not very clear. If there is this

class A:
   def foo(self):
      print("A")

class B(A):
   pass

class C(A):
   def foo(self):
      print("C")

class D:
   def foo(self):
      print("D")

class E(B, C, D):
   pass

E().foo()

So the search order for foo will be E, B, C, D, A, object? Or how. This article should not be thrown https://habr.com/en/post/62203/

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question