[ 'import sys\ ''print(sys path)\ '' \ ''print( * )\ 'per extend iterates automaticallybut append does not--use the latter (or similarto add an iterable to list without iteratingwith the potential to be iterated across laterl [ append(open('script py')list append does not iterate [ list( [ ]['import sys\ ''print(sys path)\ '' \ ''print( * )\ 'iteration is broadly supported and powerful model earlierwe saw that the built-in dict call accepts an iterable zip resulttoo (see and for that matterso does the set callas well as the newer set and dictionary comprehension expressions in python and which we met in and set(open('script py'){'print( * )\ ''import sys\ ''print(sys path)\ '' \ '{line for line in open('script py'){'print( * )\ ''import sys\ ''print(sys path)\ '' \ '{ixline for ixline in enumerate(open('script py')){ 'import sys\ ' 'print(sys path)\ ' ' \ ' 'print( * )\ 'in factboth set and dictionary comprehensions support the extended syntax of list comprehensions we met earlier in this including if tests{line for line in open('script py'if line[ =' '{'print( * )\ ''print(sys path)\ '{ixline for (ixlinein enumerate(open('script py')if line[ =' '{ 'print(sys path)\ ' 'print( * )\ 'like the list comprehensionboth of these scan the file line by line and pick out lines that begin with the letter they also happen to build sets and dictionaries in the endbut we get lot of work "for freeby combining file iteration and comprehension syntax later in the book we'll meet relative of comprehensions--generator expressions--that deploys the same syntax and works on iterables toobut is also iterable itselflist(line upper(for line in open('script py')see ['import sys\ ''print(sys path)\ '' \ ''print( * )\ 'other built-in functions support the iteration protocol as wellbut franklysome are harder to cast in interesting examples related to filesfor examplethe sum call computes the sum of all the numbers in any iterablethe any and all built-ins return true if any or all items in an iterable are truerespectivelyand max and min return the largest and smallest item in an iterablerespectively like reduceall of the tools in the following iterations and comprehensions