Chapter 4. List of Files: Functions, Modules & Files
Your code can’t live in a notebook forever. It wants to be free.
And when it comes to freeing your code and sharing it with others, a bespoke function is the first step, followed shortly thereafter by a module, which lets you organize and share your code. In this chapter, you’ll create a function directly from the code you’ve written so far, and in the process create a shareable module, too. You’ll immediately put your module to work as you process the Coach’s swim data with for loops, if statements, conditional tests, and the PSL (Python Standard Library). You’ll learn how to comment your functions, too (which is always a good idea). There’s lots to be done, so let’s get to it!
Cubicle Conversation
Sam: I’ve updated the Coach on the progress-to-date.
Alex: And is he happy?
Sam: To a point, yes. He’s thrilled things have started. However, as you can imagine, he’s only really interested in the final product, which for the Coach is the bar chart.
Alex: Which should be easy enough to do now that the most-recent notebook produces the data we need, right?
Mara: Well… sort of.
Alex: How come?
Mara: The current notebook, Times.ipynb, produces data for Darius swimming the 100m fly in the under 13 age group. But, there’s a need ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access