hing
Talkingtoyourself
Morearguments
Initializingtheobject
Explainingyourself
Modulesandpackages
Organizingthemodules
Absoluteimports
Relativeimports
Organizingmodulecontents
Whocanaccessmydata?
Third-partylibraries
Casestudy
Exercises
Summary
Chapter3:WhenObjectsAreAlike
Basicinheritance
Extendingbuilt-ins
Overridingandsuper
Multipleinheritance
Thediamondproblem
Differentsetsofarguments
Polymorphism
Abstractbaseclasses
Usinganabstractbaseclass
Creatinganabstractbaseclass
Demystifyingthemagic
Casestudy
Exercises
Summary
Chapter4:ExpectingtheUnexpected
Raisingexceptions
Raisinganexception
Theeffectsofanexception
Handlingexceptions
Theexceptionhierarchy
Definingourownexceptions
Casestudy
Exercises
Summary
Chapter5:WhentoUseObject-orientedProgramming
Treatobjectsasobjects
Addingbehaviortoclassdatawithproperties
Propertiesindetail
Decorators-anotherwaytocreateproperties
Decidingwhentouseproperties
Managerobjects
Removingduplicatecode
Inpractice
Casestudy
Exercises
Summary
Chapter6:PythonDataStructures
Emptyobjects
Tuplesandnamedtuples
Namedtuples
Dictionaries
Dictionaryusecases
Usingdefaultdict
Counter
Lists
Sortinglists
Sets
Extendingbuilt-ins
Queues
FIFOqueues
LIFOqueues
Priorityqueues
Casestudy
Exercises
Summary
Chapter7:PythonObject-orientedShortcuts
Pythonbuilt-infunctions
Thelen()function
Reversed
Enumerate
FileI/O
Placingitincontext
Analternativetomethodoverloading
Defaultarguments
Variableargumentlists
Unpackingarguments
Functionsareobjectstoo
Usingfunctionsasattributes
Callableobjects
Casestudy
Exercises
Summary
Chapter8:StringsandSerialization
Strings
Stringmanipulation
Stringformatting
Escapingbraces
Keywordarguments
ContainerIookups
ObjectIookups
Makingitlookright
StringsareUnicode
Convertingbytestotext
Convertingtexttobytes
Mutablebytestrings
Regularexpressions
Matchingpatterns
Matchingaselectionofcharacters
Escapingcharacters
Matchingmultiplecharacters
Groupingpatternstogether
Gettinginformationfromregularexpressions
Makingrepeatedregularexpressionsefficient
Serializingobjects
Customizingpickles
Serializingwebobjects
Casestudy
Exercises
Summary
Chapter9:TheIteratorPattern
Designpatternsinbrief
Iterators
Theiteratorprotocol
Comprehensions
Listcomprehensions
Setanddictionarycomprehensions
Generatorexpressions
Generators
Yielditemsfromanotheriterable
Coroutines
Backtologparsing
Closingcoroutinesandthrowingexceptions
Therelationshipbetweencoroutines,generators,andfunctions
Casestudy
Exercises
Summary
Chapter10:PythonDesignPatternsI
Thedecoratorpattern
Adecoratorexample
DecoratorsinPython
Theobserverpattern
Anobserverexample
Thestrategypattern
Astrategyexample
StrategyinPython
Thestatepattern
Astateexample
Stateversusstrategy
Statetransitionascoroutines
Thesingletonpattern
Singletonimplementation
Thetemplatepattern
Atemplateexample
Exercises
Summary
Chapter11:PythonDesignPatternsII
Theadapterpattern
Thefacadepattern
Theflyweightpattern
Thecommandpattern
Theabstractfactorypattern
Thecompositepattern
Exercises
Summary
Chapter12:TestingObject-orientedPrograms
Whytest?
Test-drivendevelopment
Unittesting
Assertionmethods
Reducingboilerplateandcleaningup
Organizingandrunningtests
Ignoringbrokentests
Testingwithpy.test
Onewaytodosetupandcleanup
Acompletelydifferentwaytosetupvariables
Skippingtestswithpy.test
Imitatingexpensiveobjects
Howmuchtestingisenough?
Casestudy
Implementingit
Exercises
Summary
Chapter13:Concurrency
Threads
Themanyproblemswiththreads
Sharedmemory
Theglobalinterpreterlock
Threadoverhead
Multiprocessing
Multiprocessingpools
Queues
Theproblemswithmultiprocessing
Futures
AsynclO
AsynclOinaction
ReadinganAsynclOfuture
AsynclOfornetworking
Usingexecutorstowrapblockingcode
Streams
Executors
Casestudy
Exercises
Summary
Index