Multiple inheritance
Multiple inheritance is a touchy subject. In principle, it's simple: a subclass that inherits from more than one parent class is able to access functionality from both of them. In practice, this is less useful than it sounds and many expert programmers recommend against using it.
Note
As a humorous rule of thumb, if you think you need multiple inheritance, you're probably wrong, but if you know you need it, you might be right.
The simplest and most useful form of multiple inheritance is called a mixin. A mixin is a superclass that is not intended to exist on its own, but is meant to be inherited by some other class to provide extra functionality. For example, let's say we wanted to add functionality to our Contact
class that allows sending an email to self.email
. Sending email is a common task that we might want to use on many other classes. So, we can write a simple mixin class to do the emailing for us:
class MailSender: def send_mail(self, message): print...