Page 20 - think python 2
P. 20
xx
Contents
17.4 Amorecomplicatedexample .......................... 164 17.5 Theinitmethod .................................. 164 17.6 The__str__method ............................... 165 17.7 Operatoroverloading............................... 165 17.8 Type-baseddispatch ............................... 166 17.9 Polymorphism................................... 167 17.10 Debugging..................................... 168 17.11 Interfaceandimplementation .......................... 169 17.12 Glossary ...................................... 169 17.13 Exercises ...................................... 170
18 Inheritance 171
18.1 Cardobjects .................................... 171 18.2 Classattributes .................................. 172 18.3 Comparingcards ................................. 173 18.4 Decks........................................ 174 18.5 Printingthedeck ................................. 174 18.6 Add,remove,shuffleandsort.......................... 175 18.7 Inheritance..................................... 176 18.8 Classdiagrams .................................. 177 18.9 Debugging..................................... 178 18.10 Dataencapsulation ................................ 179 18.11 Glossary ...................................... 180 18.12 Exercises ...................................... 181
19 The Goodies 183
19.1 Conditionalexpressions ............................. 183 19.2 Listcomprehensions ............................... 184 19.3 Generatorexpressions .............................. 185 19.4 anyandall .................................... 185 19.5 Sets......................................... 186 19.6 Counters ...................................... 187