Whole module versus module items
There are two approaches to the contents of a library module. Some modules are an integrated whole, some are more like a collection of less-well-related items. When we've designed a module as a whole, it will often have a few classes or functions that are the public-facing API of the module. When we've designed a module as a collection of loosely related items, each individual class or function tends to stand alone.
We often see this distinction in the way we import and use a module. We'll look at three variations:
Using the
import some_module
commandThe
some_module.py
module file is evaluated and the resulting objects are collected into a single namespace calledsome_module
. This requires us to use qualified names for all of the objects in the module. We must usesome_module.this
andsome_module.that
. This use of qualified names makes the module an integrated whole.Using the
from some_module import this
commandThe
some_module.py
module file is evaluated and...