Getting ready

In the Designing scripts for composition recipe, we looked at an application that produced a YAML file with the raw output of a simulation in it. In this recipe, we'll look at an application that consumes that raw data and produces some statistical summaries. We'll call this application

Following the design pattern of separating the input, output, and processing, we'll have an application main() that looks something like this:

    def main(): 
        options = get_options(sys.argv[1:]) 
        if options.output is not None: 
            report_path = Path(options.output) 
            with'w') as result_file: 
                process_all_files(result_file, options.file) 
            process_all_files(sys.stdout, options.file) 

This function will get the options ...

Get Modern Python Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.