Hướng dẫn mro is related to in python - mro có liên quan tới trong python

Thứ tự phân giải phương pháp

MRO là một khái niệm được sử dụng trong kế thừa. Đó là thứ tự mà một phương thức được tìm kiếm trong phân cấp các lớp và đặc biệt hữu ích trong Python vì Python hỗ trợ nhiều phương thức kế thừa được gọi từ một đối tượng con có thể tồn tại trong nhiều lớp siêu. is a concept used in inheritance. It is the order in which a method is searched for in a classes hierarchy and is especially useful in Python because Python supports multiple inheritancea method being called from a child object may exist in multiple super classes.

Trong Python, MRO nằm từ dưới lên trên và từ trái sang phải. Điều này có nghĩa là, trước tiên, phương thức được tìm kiếm trong lớp của đối tượng. Nếu nó không tìm thấy, nó sẽ được tìm kiếm trong siêu lớp ngay lập tức. Trong trường hợp của nhiều siêu lớp, nó được tìm kiếm từ trái sang phải, theo thứ tự được nhà phát triển tuyên bố. Ví dụ:

Lưu ý: Chúng tôi đang sử dụng Python 3.10.4 trong câu trả lời này.: We are using Python 3.10.4 in this Answer.

Trong trường hợp này, MRO sẽ là C -> B -> A. Vì B được đề cập đầu tiên trong khai báo lớp, nó sẽ được tìm kiếm đầu tiên trong khi giải quyết một phương thức.
Since B was mentioned first in the class declaration, it will be searched for first while resolving a method.

Hãy cùng xem xét một vài trường hợp, bắt đầu từ đơn giản đến phức tạp.

ví dụ 1

class A:

def method(self):

print("A.method() called")

class B(A):

def method(self):

print("B.method() called")

b = B()

b.method()

Đây là một trường hợp đơn giản với kế thừa duy nhất. Trong trường hợp này, khi b.method() được gọi, trước tiên nó tìm kiếm phương thức trong lớp B. Trong trường hợp này, lớp B đã xác định phương pháp; Do đó, nó là một trong những đã được thực hiện. Trong trường hợp nó không có trong B, thì phương pháp từ siêu lớp ngay lập tức (A) của nó sẽ được gọi. Vì vậy, MRO cho trường hợp này là: B -> a

Ví dụ 2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

MRO cho trường hợp này là: C -> B -> A Phương thức chỉ tồn tại trong A, nơi nó được tìm kiếm cuối cùng.
C -> B -> A
The method only existed in A, where it was searched for last.

Ví dụ 3

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

MRO cho điều này có thể là một chút khó khăn. Siêu lớp ngay lập tức cho D là C, vì vậy nếu phương thức không được tìm thấy trong D, thì nó sẽ được tìm kiếm trong C. Tuy nhiên, nếu nó không được tìm thấy trong C, thì bạn phải quyết định xem bạn có nên kiểm tra một (được khai báo đầu tiên trong Danh sách các lớp siêu của C) hoặc kiểm tra B (được khai báo trong danh sách các lớp siêu của D sau C). Trong Python 3 trở đi, điều này được giải quyết khi lần đầu tiên kiểm tra A. Vì vậy, MRO trở thành:

D -> c -> a -> b

Tìm hiểu về tuyến tính hóa C3 để xem tại sao.

Khi nào một ngoại lệ có thể xảy ra?

Nếu, như trong ví dụ 3 (hiển thị ở trên):

  • Thứ tự kế thừa của d là (b, c, đối tượng) object ensures that it is a new style class
  • Thứ tự kế thừa của C là (B, A)

Nó sẽ gây ra một lỗi: KiểuError: Không thể tạo một thứ tự phân giải phương thức nhất quán (MRO) cho các cơ sở B, C.
TypeError: Cannot create a consistent method resolution order (MRO) for bases B, C.

Giải thích: MRO mà chúng ta có thể suy luận từ các quy tắc chúng ta đã thấy là: d -> b -> c -> b -> a Tuy nhiên, B không nên đến trước c vì nó là một siêu lớp C. vì vậy, nó trở thành : D -> c -> b -> a Nhưng, trong khi khai báo lớp D, B được tuyên bố đầu tiên trong danh sách các siêu lớp; Vì vậy, nếu một phương thức tồn tại trong cả B và C, phiên bản nào nên gọi?
The MRO that we can deduce from the rules we have seen is: D -> B -> C -> B -> A
However, B should not come before C as it is a super class of C. So, it becomes:
D -> C -> B -> A
But, while declaring the class D, B was declared first in the list of super classes; so, if a method exists in both B and C, which version should called?

Thứ tự phân giải phương thức: & NBSP; Thứ tự phân giải phương thức (MRO) Nó biểu thị cách ngôn ngữ lập trình giải quyết một phương thức hoặc thuộc tính. Python hỗ trợ các lớp kế thừa từ các lớp khác. Lớp được kế thừa được gọi là cha mẹ hoặc siêu lớp, trong khi lớp kế thừa được gọi là con hoặc lớp con. Trong Python, thứ tự phân giải phương thức xác định thứ tự trong đó các lớp cơ sở được tìm kiếm khi thực hiện một phương thức. Đầu tiên, phương thức hoặc thuộc tính được tìm kiếm trong một lớp và sau đó nó tuân theo thứ tự chúng tôi đã chỉ định trong khi kế thừa. Thứ tự này còn được gọi là tuyến tính hóa của một lớp và tập hợp các quy tắc được gọi là MRO (thứ tự phân giải phương thức). Trong khi kế thừa từ một lớp khác, trình thông dịch cần một cách để giải quyết các phương thức được gọi thông qua một thể hiện. Do đó, chúng ta cần thứ tự phân giải phương pháp. Ví dụ: & nbsp; & nbsp; 
Method Resolution Order(MRO) it denotes the way a programming language resolves a method or attribute. Python supports classes inheriting from other classes. The class being inherited is called the Parent or Superclass, while the class that inherits is called the Child or Subclass. In python, method resolution order defines the order in which the base classes are searched when executing a method. First, the method or attribute is searched within a class and then it follows the order we specified while inheriting. This order is also called Linearization of a class and set of rules are called MRO(Method Resolution Order). While inheriting from another class, the interpreter needs a way to resolve the methods that are being called via an instance. Thus we need the method resolution order. For Example 
 

Python3

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

0

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

3

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

4

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

5

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

8class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

0

class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

3

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

4

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

5

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

8class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

0

class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

2

 In class B
6

Output:   
 

 In class B

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

8class
 In class B
2
The order that follows in the above code is- class B – > class A 
In multiple inheritances, the methods are executed based on the order specified while inheriting the classes. For the languages that support single inheritance, method resolution order is not interesting, but the languages that support multiple inheritance method resolution order plays a very crucial role. Let’s look over another example to deeply understand the method resolution order: 
 

Python3

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

0

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

3

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

4

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

5

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

8class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

0

class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

3

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

4

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

5

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

8class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

0

class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

3

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

4

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

5

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

8class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

0

class

class A:

def method(self):

print("A.method() called")

class B:

def method(self):

print("B.method() called")

class C(A, B):

pass

class D(C, B):

pass

d = D()

d.method()

2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1b.method()6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

8class
 In class B
2

 In class B
6

 In class B
3
 In class B
4
 In class B
5
 
 

 In class B

Trong ví dụ trên, các phương thức được gọi là từ lớp B nhưng không phải từ lớp A và điều này là do thứ tự phân giải phương thức (MRO). & Nbsp; thứ tự theo sau trong mã trên là lớp B-> Class A & nbsp; Trong nhiều kế thừa, các phương thức được thực thi dựa trên thứ tự được chỉ định trong khi kế thừa các lớp. Đối với các ngôn ngữ hỗ trợ kế thừa duy nhất, thứ tự phân giải phương thức không thú vị, nhưng các ngôn ngữ hỗ trợ nhiều thứ tự phân giải phương pháp kế thừa đóng một vai trò rất quan trọng. Hãy cùng xem xét một ví dụ khác để hiểu sâu sắc thứ tự giải quyết phương thức: & nbsp; & nbsp;Diamond inheritance and it looks as follows: 
 

Hướng dẫn mro is related to in python - mro có liên quan tới trong python

class Python 3.10.42
Class D -> Class B -> Class C -> Class A 
Python follows depth-first order to resolve the methods and attributes. So in the above example, it executes the method in class B. 
  
Old and New Style Order : 
In the older version of Python(2.1) we are bound to use old-style classes but in Python(3.x & 2.2) we are bound to use only new classes. New style classes are the ones whose first parent inherits from Python root ‘object’ class. 
 

Python3

class object ensures that it is a new style class2

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1b.method()6

class object ensures that it is a new style class6object ensures that it is a new style class7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

5

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1b.method()6

Thứ tự phân giải phương pháp (MRO) trong cả hai kiểu khai báo là khác nhau. Các lớp kiểu cũ sử dụng DLR hoặc độ sâu đầu tiên từ trái sang phải thuật toán trong khi các lớp kiểu mới sử dụng thuật toán tuyến tính hóa C3 để phân giải phương thức trong khi thực hiện nhiều kế thừa. Tìm kiếm vì nó cần giải quyết phương thức nào phải được gọi khi một người được gọi bởi một thể hiện. Như tên cho thấy, thứ tự độ phân giải phương thức sẽ tìm kiếm độ sâu đầu tiên, sau đó đi sang trái sang phải. Ví dụ: & nbsp; & nbsp;DLR or depth-first left to right algorithm whereas new style classes use C3 Linearization algorithm for method resolution while doing multiple inheritances. 
  
DLR Algorithm 
During implementing multiple inheritances, Python builds a list of classes to search as it needs to resolve which method has to be called when one is invoked by an instance. As the name suggests, the method resolution order will search the depth-first, then go left to right. For Example 
 

Python3

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

0

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1b.method()6

class class6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1b.method()6

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

00

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1b.method()6

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

04

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1b.method()6

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

08

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

1b.method()6

Trong thuật toán ví dụ trên trước tiên xem xét lớp thể hiện cho phương thức được gọi. Nếu không có mặt, thì nó nhìn vào cha mẹ đầu tiên, nếu điều đó cũng không có mặt sau đó là cha mẹ của cha mẹ được nhìn vào. Điều này tiếp tục cho đến khi kết thúc độ sâu của lớp và cuối cùng, cho đến khi kết thúc các lớp kế thừa. Vì vậy, thứ tự độ phân giải trong ví dụ cuối cùng của chúng tôi sẽ là D, B, A, C, A. Nhưng, A không thể có mặt hai lần như vậy, thứ tự sẽ là D, B, A, C. Nhưng thuật toán này khác nhau theo những cách khác nhau và Hiển thị các hành vi khác nhau tại các thời điểm khác nhau. Vì vậy, Samuele Pedroni lần đầu tiên phát hiện ra sự không nhất quán và giới thiệu thuật toán tuyến tính hóa C3. Nó được sử dụng để loại bỏ sự không nhất quán được tạo bởi thuật toán DLR. Nó có một số hạn chế nhất định là: & nbsp; & nbsp;
  
C3 Linearization Algorithm : 
C3 Linearization algorithm is an algorithm that uses new-style classes. It is used to remove an inconsistency created by DLR Algorithm. It has certain limitation they are: 
 

  • Trẻ em đi trước cha mẹ của chúng
  • Nếu một lớp kế thừa từ nhiều lớp, chúng được giữ theo thứ tự được chỉ định trong bộ thuật của lớp cơ sở.

Thuật toán tuyến tính hóa C3 hoạt động trên ba quy tắc: & nbsp; & nbsp;
 

  • Biểu đồ kế thừa xác định cấu trúc của thứ tự phân giải phương pháp.
  • Người dùng chỉ phải truy cập lớp siêu chỉ sau khi phương thức của các lớp địa phương được truy cập.
  • Tính đơn điệu

& nbsp; & nbsp; Phương thức cho thứ tự phân giải phương thức (MRO) của một lớp: & nbsp; để có được thứ tự phân giải phương thức của một lớp chúng ta có thể sử dụng thuộc tính __mro__ hoặc mro (). Bằng cách sử dụng các phương pháp này, chúng ta có thể hiển thị thứ tự trong đó các phương thức được giải quyết. Ví dụ: & nbsp; & nbsp;
Methods for Method Resolution Order(MRO) of a class: 
To get the method resolution order of a class we can use either __mro__ attribute or mro() method. By using these methods we can display the order in which methods are resolved. For Example 
 

Python3

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

0

class class6

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

00

class class6

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

00

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

04

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

00

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

04

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

6

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

44

class

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

08

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

49

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

7

class A:

def method(self):

print("A.method() called")

class B:

pass

class C(B, A):

pass

c = C()

c.method()

51

Output:   
 

Constructor C

(, , , )

[, , , ]

MRO trong Python là gì?

Thứ tự phân giải phương thức (MRO) Nó biểu thị cách ngôn ngữ lập trình giải quyết một phương thức hoặc thuộc tính. Python hỗ trợ các lớp kế thừa từ các lớp khác. Lớp được kế thừa được gọi là cha mẹ hoặc siêu lớp, trong khi lớp kế thừa được gọi là con hoặc lớp con.(MRO) it denotes the way a programming language resolves a method or attribute. Python supports classes inheriting from other classes. The class being inherited is called the Parent or Superclass, while the class that inherits is called the Child or Subclass.

Làm thế nào MRO được tính toán trong Python?

Để có được MRO của một lớp, bạn có thể sử dụng thuộc tính __mro__ hoặc phương thức MRO (). Thuộc tính __mro__ trả về một tuple, nhưng phương thức mro () trả về một danh sách python. Để lấy một ví dụ phức tạp hơn cũng thể hiện tìm kiếm chiều sâu đầu tiên, chúng tôi lấy 6 lớp. Chúng ta có thể đại diện cho điều này với sơ đồ sau.use either the __mro__ attribute or the mro() method. The __mro__ attribute returns a tuple, but the mro() method returns a python list. To take a more complex example that also demonstrates depth-first search, we take 6 classes. We can represent this with the following diagram.

MRO được tính toán như thế nào?

MRO được sử dụng chủ yếu để có được thứ tự trong đó các phương pháp nên được kế thừa với sự hiện diện của nhiều khoản thừa kế.Python 3 sử dụng thuật toán tuyến tính hóa C3 cho MRO.L [c] = c + hợp nhất tuyến tính hóa cha mẹ của C và danh sách cha mẹ của C theo thứ tự họ được thừa hưởng từ trái sang phải.L[C] = C + merge of linearization of parents of C and list of parents of C in the order they are inherited from left to right.

Làm cách nào để thay đổi MRO trong Python?

Metaclass cung cấp phương thức MRO, mà chúng ta quá tải, được gọi là trong quá trình tạo lớp (cuộc gọi Metaclass '__New__) để tạo thuộc tính __mro__ ...
Một phương thức MRO quá tải ..
Phương thức lớp để thay đổi thuộc tính __mro__ ..
Thuộc tính lớp (thay đổi_mro) để kiểm soát hành vi MRO ..