liveBook · Manning

__all__

__all__ is a module-level sequence of names specifying which names a Python module exports for wildcard imports.

How 3 Manning books explain it

The Quick Python Book, Fourth Edition

__all__ is a module-level sequence that specifies the names exported by a wildcard import.

How it is used
Controls which names wildcard imports expose from modules and packages.
How deep it goes
Defines export selection and demonstrates package behavior, but stops short of recursive importing and deeper package mechanics.
Examples
Demonstrates mathproj, comp, c1, and explicit imports through short interactive results.
What you can do after
Apply it via Python wildcard imports to select exported package names and avoid unintended names.

Read how The Quick Python Book, Fourth Edition explains __all__ →

Python Workout: 50 ten-minute exercises

__all__ is a module-level sequence that specifies which names are exported by a wildcard import from that module.

How it is used
Controls the names exposed when another program uses a wildcard import from a module.
How deep it goes
Defines the export-selection behavior and assigns a small construction exercise, without discussing import internals.
Examples
Uses a stuff module containing a, b, c, foo, and bar to select a, c, and bar.
What you can do after
Build it from scratch by defining __all__ for a module’s wildcard-import interface.

Read how Python Workout: 50 ten-minute exercises explains __all__ →

Python Workout, Second Edition

__all__ is a module-level sequence of names that defines the names exported by a wildcard import.

How it is used
Controls which names a wildcard import brings into the importing namespace.
How deep it goes
Defines an export sequence through a focused exercise, without detailing wildcard-import internals.
Examples
Uses a stuff module containing a, b, c, foo, and bar, selecting a, c, and bar.
What you can do after
Apply it via Python imports by defining a module’s desired wildcard-import names.

Read how Python Workout, Second Edition explains __all__ →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.