April 2014
Beginner to intermediate
634 pages
15h 22m
English
In this chapter, we looked at the essential ingredients of abstract base classes. We saw a few features of each kind of abstraction.
We also learned that one rule for good class design is to inherit as much as possible. We saw two broad patterns here. We also saw common exceptions to this rule.
Some application classes don't have behaviors that overlap with internal features of Python. From our Blackjack examples, a Card isn't much like a number, a container, an iterator, or a context. It's just a playing card. In this case, we can generally invent a new class because there isn't any built-in features to inherit fro.
When we look at Hand, however, we see that a hand is clearly a container. As we noted ...