[Note: I have had to strip most of the citation links from this post, as the interface won’t allow me to include more than two links.
]
Technically speaking, a Python package is a module. However, throughout the Python documentation and the PEPs we find abundant instances of language which implies that “modules” by itself would not include packages. For example:
Python supports modules and packages …
… or in the unittest documentation:
… all of the test files must be modules or packages …
… or in the official Python tutorial:
A module is a file containing Python definitions and statements.
The result of these discrepancies is that (at least in my experience) the average Python user assumes that “modules” does not include packages. That’s usually not a serious problem, but it does result in some occasional head-scratching, for example as when reading this paragraph in the Django documentation:
Once you have defined your models, you need to tell Django you’re going to use those models. Do this by editing your settings file and changing the
INSTALLED_APPSsetting to add the name of the module that contains yourmodels.py.
Strictly. speaking, the use of the word “module” in that passage is correct, but if the reader has just finished reading the official Django tutorial, where that location is referred to as a “package,” I can easily imagine this being a “Wait, what?” moment.
I wonder if it might be helpful to acknowledge this second (arguably more common) meaning of the word “module” explicitly somewhere in the Python documentation (perhaps in the glossary) with some encouragement to use “package” instead when the word in question can only refer to a package, and to use “module or package” when referring to a module which might or might not also be a package.
What do others think?