Control Exported Names with __all__ in Python

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']

  • No alternative text description for this image

And don't forget to use a module based naming convention, so you don't actually import x, y and z 😵💫

To view or add a comment, sign in

Explore content categories