Five more functions. make_crosstab_line, summarize_group, parse_survey_csv, load_responses_from_csv, responses_to_json. Which concept shifted your thinking the most?
io.StringIO. I didn't know you could wrap a string into a fake file object. That unlocked csv.DictReader without needing a real file — and it means any API response that comes back as a CSV string can be parsed the same way.
That's the generalisation. The interface is what matters — DictReader just needs something that behaves like a file. What about default arguments?
summarize_group(responses) uses year-in-school by default — the column my advisor always wants. Passing a different field overrides it. I'm encoding assumptions into the function signature instead of hardcoding them.
That's the difference between a function and a script. Scripts hardcode; functions parameterise. Six questions — two from Weeks 1 and 2.
Ready.
All six functions from Weeks 1 through 3 are still in the pipeline. Keep them sharp.
Five more functions. make_crosstab_line, summarize_group, parse_survey_csv, load_responses_from_csv, responses_to_json. Which concept shifted your thinking the most?
io.StringIO. I didn't know you could wrap a string into a fake file object. That unlocked csv.DictReader without needing a real file — and it means any API response that comes back as a CSV string can be parsed the same way.
That's the generalisation. The interface is what matters — DictReader just needs something that behaves like a file. What about default arguments?
summarize_group(responses) uses year-in-school by default — the column my advisor always wants. Passing a different field overrides it. I'm encoding assumptions into the function signature instead of hardcoding them.
That's the difference between a function and a script. Scripts hardcode; functions parameterise. Six questions — two from Weeks 1 and 2.
Ready.
All six functions from Weeks 1 through 3 are still in the pipeline. Keep them sharp.