__all__ is a module- or package-level list of strings that selects the names made available by a wildcard import. In a package’s __init__.py, it defines that package’s wildcard-import surface. section 18.4 section 10.3
Use the following rules when reading or defining __all__:
- Set it to the exact names that should be imported by from package_or_module import *. section 18.4
- Do not expect wildcard imports to recurse into subpackages; import deeper names explicitly. section 18.4
- Prefer leading underscores for elements that should remain nonpublic rather than using __all__ merely to hide them. section 18.7 section 18.5
Selecting package exports
With mathproj/__init__.py containing __all__ = ['comp'], from mathproj import * makes comp available. It does not make comp.c1 available; that requires from mathproj.comp import c1. section 18.3 section 18.4
from mathproj import * Hello from mathproj init Hello from mathproj.comp init
Shows the wildcard import, package initialization output, and the resulting exported comp name. section 18.4


