AI, Data Science & Cloud Certificates from Google, IBM & Meta
The Private Equity Associate Certification
Overview
Google, IBM & Meta Certificates – 40% Off
One plan covers every Professional Certificate on Coursera.
Unlock All Certificates
This 43-minute PyCon US talk explores three different approaches to implementing polymorphism in Python, comparing their strengths and weaknesses in practical programming scenarios. Dive into the limitations of using isinstance() checks, which often leads to code duplication, and understand why traditional OOP method polymorphism can result in code being organized inefficiently, hampering understandability and maintenance. Discover the power of @singledispatch from the functools library, which offers an elegant balance between functional and object-oriented programming paradigms. Learn how this lesser-known feature works under the hood and how to implement or integrate similar functionality into your own programs to achieve polymorphic behavior while using simple functions and plain data objects instead of classes. Gain practical insights for writing more maintainable Python code that leverages the language's multi-paradigm nature effectively.
Syllabus
The Zen of Polymorphism: Choosing between isinstance(), methods, and @singledispatch
Taught by
PyCon US