Imagine the following high-level logical flow for a simple report generator program:
Read input data
Perform calculations
Write report
Notice how each stage (after the first one) depends on some byproduct or output of its predecessor:
Read input data
Perform calculations (based on input data)
Write report (based on calculated report data)
This is just about structuring the code in such a way that methods come like this below
def read_input_file(filename):
pass
def generate_report(data):
pass
def write_report(report):
pass
data = read_input_file('data.csv')
report = generate_report(data)
write_report(report)
References:
https://dbader.org/blog/how-to-structure-python-programs
No comments:
Post a Comment