liveBook · Manning

__all__

As explained in Python Workout, Second Edition

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

__all__ is a module-level sequence of names that controls which names a wildcard import makes available. section 9.9

Select exported names

For a module named stuff containing a, b, c, foo, and bar, define __all__ so that from stuff import * imports a, c, and bar while excluding b and foo: __all__ = ["a", "c", "bar"] section 9.9

How Python Workout, Second Edition covers it

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.
How it connects
Connects wildcard imports with modules, packages, and PyPI distribution.

Also explained in

Compare how 3 books explain __all__ →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python Workout, Second Edition. The section links point to the parts of the book it draws on.