Leveraging Python's duck typing
When a design involves inheritance, there is often a clear relationship from a superclass to one or more subclasses. In the Choosing between inheritance and extension – the is-a question recipe of this chapter, as well as the Extending a collection – a list that does statistics recipe in Chapter 7, Basics of Classes and Objects, we've looked at extensions that involve a proper subclass-superclass relationship.
In order to have classes that can be used in place of one another ("polymorphic" classes), some languages require a common superclass. In many cases, the common class doesn't have concrete implementations for all of the methods; it's called an abstract superclass.
Python doesn't require common superclasses. The standard library, however, does offer the abc
module. This provides optional support creating abstract classes in cases where it can help to clarify the relationships among classes...