Python Practical Notes (25) Object-Oriented Advanced Programming - Multiple Inheritance

class Dog(Mammal, Runnable):
    pass 

Multiple inheritance inherits all the functions of different classes. This design is called Mixln, and its purpose is to add multiple functions to a class. In this way, when designing a class, we give priority to combining multiple MixIns through multiple inheritance. functions, rather than designing multiple levels of complex inheritance relationships.

Such as:

class MyTCPServer(TCPServer, ForkingMixIn):
    pass 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326002766&siteId=291194637