8 More Advanced Class Design
In Chapter 7, we looked at some recipes that covered the basics of class design. In this chapter, we’ll dive more deeply into Python classes and class design.
In the Designing classes with lots of processing and Using properties for lazy attributes recipes in Chapter 7, we identified a design choice that’s central to object-oriented programming, the ”wrap versus extend” decision. One way to add features is to create a new subclass via an extension. The other technique for adding features is to wrap an existing class, making it part of a new class.
In addition to direct inheritance, there are some other class extension techniques available in Python. A Python class can inherit features from more than one superclass. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access