__all__

Dunder AttributePython 2.0+Intermediate

List of public names exported by a module with 'from module import *'

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# __all__ controls what 'from module import *' exports
# In a module, you would define:
# __all__ = ["public_func", "PublicClass"]
print("__all__ is typically defined at module level")
print("It restricts star imports to listed names only")
import math
print(hasattr(math, "__all__"))

__all__ is a special attribute that list of public names exported by a module with 'from module import *'.

Try in Playground

Tags

oopintrospectioncore