Learning Python, 5th Edition - cdn.oreilly.com
Learning Python, 5th Edition - cdn.oreilly.com
Learning Python, 5th Edition - cdn.oreilly.com
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Using Code Two Ways 820<br />
Step 2: Adding Behavior Methods 822<br />
Coding Methods 824<br />
Step 3: Operator Overloading 826<br />
Providing Print Displays 826<br />
Step 4: Customizing Behavior by Subclassing 828<br />
Coding Subclasses 828<br />
Augmenting Methods: The Bad Way 829<br />
Augmenting Methods: The Good Way 829<br />
Polymorphism in Action 832<br />
Inherit, Customize, and Extend 833<br />
OOP: The Big Idea 833<br />
Step 5: Customizing Constructors, Too 834<br />
OOP Is Simpler Than You May Think 836<br />
Other Ways to Combine Classes 836<br />
Step 6: Using Introspection Tools 840<br />
Special Class Attributes 840<br />
A Generic Display Tool 842<br />
Instance Versus Class Attributes 843<br />
Name Considerations in Tool Classes 844<br />
Our Classes’ Final Form 845<br />
Step 7 (Final): Storing Objects in a Database 847<br />
Pickles and Shelves 847<br />
Storing Objects on a Shelve Database 848<br />
Exploring Shelves Interactively 849<br />
Updating Objects on a Shelve 851<br />
Future Directions 853<br />
Chapter Summary 855<br />
Test Your Knowledge: Quiz 855<br />
Test Your Knowledge: Answers 856<br />
29. Class Coding Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 859<br />
The class Statement 859<br />
General Form 860<br />
Example 860<br />
Methods 862<br />
Method Example 863<br />
Calling Superclass Constructors 864<br />
Other Method Call Possibilities 864<br />
Inheritance 865<br />
Attribute Tree Construction 865<br />
Specializing Inherited Methods 866<br />
Class Interface Techniques 867<br />
Table of Contents | xxi