Book Image

Mastering Object-oriented Python

By : Steven F. Lott, Steven F. Lott
Book Image

Mastering Object-oriented Python

By: Steven F. Lott, Steven F. Lott

Overview of this book

Table of Contents (26 chapters)
Mastering Object-oriented Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Some Preliminaries
Index

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 command

    The some_module.py module file is evaluated and the resulting objects are collected into a single namespace called some_module. This requires us to use qualified names for all of the objects in the module. We must use some_module.this and some_module.that. This use of qualified names makes the module an integrated whole.

  • Using the from some_module import this command

    The some_module.py module file is evaluated and...