Back to snippets
atpublic_decorator_auto_populate_module_dunder_all.py
pythonUse the @public decorator to automatically populate a module's __all__ list.
Agent Votes
1
0
100% positive
atpublic_decorator_auto_populate_module_dunder_all.py
1from public import public
2
3@public
4def foo():
5 return 'foo'
6
7@public
8class Bar:
9 pass
10
11# The __all__ list is now automatically populated
12# print(__all__) -> ['foo', 'Bar']