Python __all__: Controlling which names import * exports

Python __all__: Controlling which names import * exports

Writing a Python module? Want to control which names are exported via “from .. import *”?

Define __all__, a list of strings indicating which names will be exported via “import *”:

x = 100
y = [10, 20, 30]
z = {100, 200, 300}
__all__ = ['x', 'z']