By using this decorator on functions or classes you achieve the same goal
as by filling __all__ variables manually, you just don’t have to repeat
your self (object’s name). You also know if object is public at definition
site, not at some random location (where __all__ was set).

Note that in multiple decorator setup, in almost all cases, @public
decorator must be applied before any other decorators, because it relies
on the pointer to object’s global namespace. If you apply other decorators
first, @public may end up modifying wrong namespace.

Example:

>>> fromsympy.utilities.decoratorimportpublic

>>> __all__Traceback (most recent call last):...NameError: name '__all__' is not definedTraceback (most recent call last):...NameError: name '__all__' is not defined