June 2019
Beginner to intermediate
770 pages
19h 24m
English
Here's an example that shows us why we shouldn't put unique, working code into the __main__.py module. We'll show you a quick hypothetical example based on extending an existing package.
Imagine that we have a generic statistical package, named analysis, with a top-level __main__.py module. This implements a command-line interface that will compute descriptive statistics of a given CSV file. This application has a command-line API as follows:
python3 -m analysis -c 10 some_file.csv
This command uses a -c option to specify which column to analyze. The input filename is provided as a positional argument on the command line.
Let's assume, further, that we have a terrible design problem. We've defined a high-level function, ...
Read now
Unlock full access