Hi Ethan, I'm sorry, I take that back, that convention was codified in PEP8.
https://www.python.org/dev/peps/pep-0008/#id50 Best, George On Wed, Mar 3, 2021 at 10:18 PM George Harding < george.winton.hard...@gmail.com> wrote: > 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: > > https://docs.python.org/3/tutorial/modules.html > > And similar the first result for __all__ on google, is a stack overflow > post stating that it is for from foo import *: > > https://stackoverflow.com/questions/44834/can-someone-explain-all-in-python > > Best, > > George > > On Wed, Mar 3, 2021 at 9:47 PM Ethan Furman <et...@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-le...@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/ >> >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@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/TBSDL7OA2LMV7VTMRUVD2DTXIFDKN2NV/ Code of Conduct: http://python.org/psf/codeofconduct/