Back to feed

Managing Imports With Python's __all__

Real Python

EDITOR BRIEF

Python's __all__ variable helps control what gets imported with a wildcard import. It also defines which names a module or package presents as its public API, helping you choose what to expose.

INSIGHTS

This matters because it helps you write cleaner, easier-to-use modules. A good next step is to practice setting __all__ in a small package and compare it with normal imports.

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

COMMENTS

0/40
0/2000

Loading comments…