Subclassing, Composition, Python, and You
summary
Covers the trade-offs between subclassing and composition in Python, distinguishing different kinds of subclassing and when each is appropriate. Uses concrete, Python-centric patterns and examples to show how to choose between inheritance and composition so code becomes clearer and more idiomatic.
AI-written summary · about
chapters (10)
- 0:00Start
- 1:41Subclassing
- 2:19@dataclass class Base
- 4:32Composition
- 16:29Nominal Subtyping
- 18:38Structural Subtyping
- 26:55class Question (django.db.models.Model)
- 36:40Exceptions
- 38:21E-Mail Addresses
- 39:56Create One Class, Make Fields Optional
related talks
41mSubclassing vs Composition: A Survey of Trade-offs in Python
37mThe Dangers of Inheritance: Why Composition Is Preferable
57mThe Art of Subclassing
36mPractical Python Design Patterns
46mOn Being Pythonic
01h 10mIt's Pythons All The Way Down: Python Types & Metaclasses Made Simple
01h 30mPython Design Patterns
32mEasier Classes: Python Classes Without All the Cruft
