What is a module?

Creating a module

Compiled Python Files

__pycache__ automatically created when you run a module for the first time.

Module Search Path

import pantry
import path

print(sys.path) # prints out all the directories where Python will look for modules

Packages

A package is a container for one or more modules. A package is mapped to a directory whereas a module is mapped to a file.

Sub-packages

Intra-package Reference

from pantry.shelf import fruit # absolute imports

The dir() function


print(dir(sales))
print(sales.__name__)
print(sales.__package__)
print(sales.__file__)