in the preceding mentioned that the for loop can work on any sequence type in pythonincluding liststuplesand stringslike thisfor in [ ]print( * end=' in xprint * for in ( )print( * end=' for in 'spam'print( end='ss pp aa mm actuallythe for loop turns out to be even more generic than this--it works on any iterable object in factthis is true of all iteration tools that scan objects from left to right in pythonincluding for loopsthe list comprehensions we'll study in this in membership teststhe map built-in functionand more the concept of "iterable objectsis relatively recent in pythonbut it has come to permeate the language' design it' essentially generalization of the notion of sequences--an object is considered iterable if it is either physically stored sequenceor an object that produces one result at time in the context of an iteration tool like for loop in senseiterable objects include both physical sequences and virtual sequences computed on demand terminology in this topic tends to be bit loose the terms "iterableand "iteratorare sometimes used interchangeably to refer to an object that supports iteration in general for claritythis book has very strong preference for using the term iterable to refer to an object that supports the iter calland iterator to refer to an object returned by an iterable on iter that supports the next(icall both these calls are defined ahead that convention is not universal in either the python world or this bookthough"iteratoris also sometimes used for tools that iterate extends this category with the term "generator"--which refers to objects that automatically support the iteration protocoland hence are iterable--even though all iterables generate resultsthe iteration protocolfile iterators one of the easiest ways to understand the iteration protocol is to see how it works with built-in type such as the file in this we'll be using the following input file to demonstrateprint(open('script py'read()import sys iterations and comprehensions