liveBook · Manning

Wildcard import

As explained in Python Workout, Second Edition

A wildcard import imports the names designated for export by a module rather than naming each imported name individually.

A wildcard import uses `from module import *` to bring in the names designated for export, instead of naming each imported name individually. section 9.9

Control the imported names

Define module `stuff` with variables `a`, `b`, and `c`, plus functions `foo` and `bar`. Set `__all__` so `from stuff import *` imports `a`, `c`, and `bar`, but not `b` or `foo`. section 9.9

How Python Workout, Second Edition covers it

How deep it goes
Defines __all__ through a focused exercise, but does not develop wildcard-import internals or broader trade-offs.
Examples
Uses module stuff with variables a, b, c and functions foo, bar to demonstrate selective exports.
What you can do after
Build it from scratch by defining __all__ to control names imported with wildcard syntax.
How it connects
Connects wildcard import to modules, packages, and __all__.

Also explained in

Compare how 2 books explain wildcard import →

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.