generators generator expressions are actually sort of comprehension toothey compress the more advanced (this time it really is more advanced!generator syntax into one line the greater generator syntax looks even less object-oriented than anything we've seenbut we'll discover that once againit is simple syntax shortcut to create kind of object let' take the log file example little further if we want to delete the warning column from our output file (since it' redundantthis file contains only warnings)we have several optionsat various levels of readability we can do it with generator expressionimport sys innameoutname sys argv[ : with open(innameas infilewith open(outname" "as outfilewarnings ( replace('\twarning'''for in infile if 'warningin lfor in warningsoutfile write(lthat' perfectly readablethough wouldn' want to make the expression much more complicated than that we could also do it with normal for loopimport sys innameoutname sys argv[ : with open(innameas infilewith open(outname" "as outfilefor in infileif 'warningin loutfile write( replace('\twarning''')that' maintainablebut so many levels of indent in so few lines is kind of ugly more alarminglyif we wanted to do something different with the linesrather than just printing them outwe' have to duplicate the looping and conditional codetoo now let' consider truly object-oriented solutionwithout any shortcutsimport sys innameoutname sys argv[ : class warningfilterdef __init__(selfinsequence)