for objects that support its context manager model summary that' as many overloading examples as we have space for here most of the other operator overloading methods work similarly to the ones we've exploredand all are just hooks for intercepting built-in type operations some overloading methodsfor examplehave unique argument lists or return valuesbut the general usage pattern is the same we'll see few others in action later in the book uses __enter__ and __exit__ in with statement context managers uses the __get__ and __set__ class descriptor fetch/set methods uses the __new__ object creation method in the context of metaclasses in additionsome of the methods we've studied heresuch as __call__ and __str__will be employed by later examples in this book for complete coveragethoughi'll defer to other documentation sources--see python' standard language manual or reference books for details on additional overloading methods in the next we leave the realm of class mechanics behind to explore common design patterns--the ways that classes are commonly used and combined to optimize code reuse after thatwe'll survey handful of advanced topics and move on to exceptionsthe last core subject of this book before you read onthoughtake moment to work through the quiz below to review the concepts we've covered test your knowledgequiz what two operator overloading methods can you use to support iteration in your classes what two operator overloading methods handle printingand in what contexts how can you intercept slice operations in class how can you catch in-place addition in class when should you provide operator overloadingtest your knowledgeanswers classes can support iteration by defining (or inheriting__getitem__ or __iter__ in all iteration contextspython tries to use __iter__ firstwhich returns an object that supports the iteration protocol with __next__ methodif no __iter__ is found by inheritance searchpython falls back on the __getitem__ indexing methodtest your knowledgeanswers