__all__ Explained

Tagged: ,

This topic was published by and viewed 1327 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author
    Posts

  • DevynCJohnson
    Keymaster
    • Topics - 437
    • @devyncjohnson

    In Python, "__all__" is a special variable that is commonly used in libraries.

    "__all__" should be near the top of  a script before any imports are performed and before defining any classes, variables, or functions. When the library is imported, "__all__" acts like an index of importable objects within the library. In other words, this variable lists public objects. So, running "from LIBRARY import *" will only import the objects listed in the "__all__" variable.

    __all__ = [
    'FUNCTION1',
    'FUNCTION2',
    'FUNCTION3',
    ]

    Further Reading

Viewing 1 post (of 1 total)