Hi Ethan,I'm not convinced that __all__ is responsible for codifying the api. The contents of __all__, does not stop anyone from importing anything in the module using `from foo import bar`. __all__ is specified in the tutorial as being included for the `from foo import *` case:And similar the first result for __all__ on google, is a stack overflow post stating that it is for from foo import *:Best,GeorgeOn Wed, Mar 3, 2021 at 9:47 PM Ethan Furman <ethan@stoneleaf.us> wrote:On 3/3/21 12:55 PM, George Harding wrote:
> Python has an __all__ variable that can be defined in a module to restrict
> which members of the module should be included in a call `from foo import *`.
The primary purpose these days for `__all__` is to codify a module's API. The *-import is just a happy accident.
> However specifying which members of the module should be excluded is more
> difficult.
And unnecessary -- specify `__all__` so your users know which classes, functions, variables, etc., can be safely used. If it should be excluded, don't put it in `__all__`.
--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EPNXFKCBYTCQVEWLZZGLR2XUKXXVJEQC/
Code of Conduct: http://python.org/psf/codeofconduct/