in particularuser-defined iterables defined with classes allow arbitrary objects and operations to be used in any of the iteration contexts we've met in this by supporting just single operation--iteration--objects may be used in wide variety of contexts and tools summary in this we explored concepts related to looping in python we took our first substantial look at the iteration protocol in python-- way for nonsequence objects to take part in iteration loops--and at list comprehensions as we sawa list comprehension is an expression similar to for loop that applies another expression to all the items in any iterable object along the waywe also saw other built-in iteration tools at work and studied recent iteration additions in python this wraps up our tour of specific procedural statements and related tools the next closes out this part of the book by discussing documentation options for python code though bit of diversion from the more detailed aspects of codingdocumentation is also part of the general syntax modeland it' an important component of wellwritten programs in the next we'll also dig into set of exercises for this part of the book before we turn our attention to larger structures such as functions as usualthoughlet' first exercise what we've learned here with quiz test your knowledgequiz how are for loops and iterable objects related how are for loops and list comprehensions related name four iteration contexts in the python language what is the best way to read line by line from text file today what sort of weapons would you expect to see employed by the spanish inquisitiontest your knowledgeanswers the for loop uses the iteration protocol to step through items in the iterable object across which it is iterating it first fetches an iterator from the iterable by passing the object to iterand then calls this iterator object' __next__ method in on each iteration and catches the stopiteration exception to determine when to stop looping the method is named next in xand is run by the next built-in function in both and any object that supports this model works in for loop and test your knowledgeanswers