let' adapt the generator example bit so that instead of accepting sequence of linesit accepts filename this would normally be frowned upon as it ties the object to particular paradigm when possible we should operate on iterators as inputthis way the same function could be used regardless of whether the log lines came from filememoryor web-based log aggregator so the following example is contrived for pedagogical reasons this version of the code illustrates that your generator can do some basic setup before yielding information from another iterable (in this casea generator expression)import sys innameoutname sys argv[ : def warnings_filter(infilename)with open(infilenameas infileyield from replace('\twarning'''for in infile if 'warningin filter warnings_filter(innamewith open(outname" "as outfilefor in filteroutfile write(lthis code combines the for loop from the previous example into generator expression notice how put the three clauses of the generator expression (the transformationthe loopand the filteron separate lines to make them more readable notice also that this transformation didn' help enoughthe previous example with for loop was more readable so let' consider an example that is more readable than its alternative it can be useful to construct generator that yields data from multiple other generators the itertools chain functionfor exampleyields data from iterables in sequence until they have all been exhausted this can be implemented far too easily using the yield from syntaxso let' consider classic computer science problemwalking general tree common implementation of the general tree data structure is computer' filesystem let' model few folders and files in unix filesystem so we can use yield from to walk them effectivelyclass filedef __init__(selfname)