Building a Python package
Building packages is considered good coding practice since it allows for writing modular code and reuse. Modular code is code that is written in many smaller pieces for more pervasive use, without needing to know the underlying implementation details of everything involved in a task. For example, when we use matplotlib
to plot something, we don't need to know what the code inside the functions we call is doing exactly—it suffices to simply know what the input and output will be to build on top of it.
Package structure
A module is a single file of Python code that can be imported; window_calc.py
from Chapter 4, Aggregating Pandas DataFrames, and viz.py
from Chapter 6, Plotting with Seaborn and Customization Techniques, were both modules. A package is a collection of modules organized into directories. Packages can also be imported, but when we import a package we have access to certain modules inside, so we don't have to import each one...