received (yield next_quarterif received is nonenext_quarter + elsenext_quarter received the yield expression returns each value to the caller in turn in additionif the caller calls the generator' send(methodthe value sent is received in the generator function as the result of the yield expression here is how we can use the new generator functionresult [generator quarters(while len(result next(generatorif abs( sys float_info epsilonx generator send( result append(xwe create variable to refer to the generator and call the built-in next(function which retrieves the next item from the generator it is given (the same effect can be achieved by calling the generator' __next__(special methodin this casex generator __next__(if the value is equal to we send the value into the generator (which immediately yields this value backthis time the result list is [ in the next subsection we will review the magic-numbers py program which processes files given on the command line unfortunatelythe windows shell program (cmd exedoes not provide wildcard expansion (also called file globbing)so if program is run on windows with the argument *the literal text "*will go into the sys argv list instead of all the files in the current directory we solve this problem by creating two different get_files(functionsone for windows and the other for unixboth of which use generators here' the codeif sys platform startswith("win")def get_files(names)for name in namesif os path isfile(name)yield name elsefor file in glob iglob(name)if not os path isfile(file)continue yield file elsedef get_files(names)return (file for file in names if os path isfile(file)