Tips for Grouping Your Functions
Put functions and variables that logically belong together in the same module. If there isn’t some logical connection—for example, if one of the functions calculates how much carbon monoxide different kinds of cars produce, while another figures out bone strength given the bone’s diameter and density—then you shouldn’t put them in one module just because you happen to be the author of both.
Of course, people often have different opinions about what is logical and what isn’t. Take Python’s math module, for example; should functions to multiply matrices go in there too, or should they go in a separate linear algebra module? What about basic statistical functions? Going back to the previous paragraph, should a ...
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