Test Your Knowledge: Quiz

 

 
  1. When we fetch a Manager object from the shelve and print it, where does the display format logic come from?
  2. 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?
  3. Why is it so important to move processing into methods, instead of hardcoding it outside the class?
  4. Why is it better to customize by subclassing rather than copying the original and modifying?
  5. 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?
  6. 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?
  7. In general terms, when might you choose to use object embedding and composition instead of inheritance?
  8. How might you modify the classes in this chapter to implement a personal contacts database in Python?