One of the key elements of OOP is inheritance, which allows you to base a new class on an existing one. By doing so, the new class automatically gets (or inherits) all of the methods and attributes of the existing class—it's like getting all of the work that went into writing the existing class for free!
TRAP | In Python, it's possible to create a new class that directly inherits from more than one class. This is called multiple inheritance. But multiple inheritance is a thorny subject and can get confusing fast. In fact, several of the most popular modern languages, such as C# and Java, have eliminated multiple inheritance and opted for the simpler, yet still powerful, single inheritance—where an object can inherit from only one class. As a beginning programmer, it's best to steer clear of multiple inheritance since it can be more heartache than help. |