已读64%
预计阅读本页时间:-
预计阅读本页时间:-
Test Your Knowledge: Quiz
- When we fetch a Manager object from the shelve and print it, where does the display format logic come from?
- When we fetch a Person object from a shelve without importing its module, how does the object know that it has a giveRaise method that we can call?
- Why is it so important to move processing into methods, instead of hardcoding it outside the class?
- Why is it better to customize by subclassing rather than copying the original and modifying?
- Why is it better to call back to a superclass method to run default actions, instead of copying and modifying its code in a subclass?
- Why is it better to use tools like __dict__ that allow objects to be processed generically than to write more custom code for each type of class?
- In general terms, when might you choose to use object embedding and composition instead of inheritance?
- How might you modify the classes in this chapter to implement a personal contacts database in Python?