Python for Developers

First Edition

Chapter 10: Packages

Packages are folders that are identified by the interpreter by the presence of a file named Packages work as collections to organize hierarchically modules.


You can import all package modules using the statement from packagename import *.

The file can be empty or contain package initialization code or define a variable called __all__, a list of modules of the package that will be imported when using "*". Without the file, Python does not recognize the folder as a valid packet.

In [1]: