Save 40% on 3 months of Coursera Plus
Power BI Fundamentals - Create visualizations and dashboards from scratch
Overview
Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
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