Back to feed

Managing Python Imports with __all__

Real Python
Managing Python Imports with __all__

EDITOR BRIEF

Python’s __all__ variable controls what gets imported when someone uses a wildcard import, like from module import *. It also helps define which names a module or package presents as part of its public API.

INSIGHTS

If you’re building Python modules, __all__ can make your code easier to use and less confusing. Try adding it to a small package and see how it changes wildcard imports.

CodeFriends courses that build on this story. Practice in the browser with nothing to install.

COMMENTS

0/40
0/2000

Loading comments…