Now you know that Python uses duck typing in many language constructs. This type of polymorphism doesn’t rely on inheritance. It only depends on the public methods and attributes (API) of objects. Many Python built-in classes and tools support this type system, which adds flexibility and power to the language.
In this video course, you’ve learned:
- What duck typing is and what its pros and cons are
- How Python’s classes and tools take advantage of duck typing
- How special methods and protocols support duck typing
- What alternatives to duck typing you’ll have in Python
Learning about duck typing will help you better understand how Python works. It can also help you write more Pythonic, flexible, and decoupled code.