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 ...
Get Mastering Object-oriented Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.