I avoid __all__ like the plague. Too easy for it to get out of sync with the API when i forget to add a new symbol.
On Wed, Mar 16, 2016 at 6:52 PM, Rick Johnson <firstname.lastname@example.org> wrote:> Besides, why is "import x as _x" so special to require special syntax?It's not :-) I know I do, for instance,from matplotlib import pylot as pltBut have NEVER done the leading underscore thing...from module import Foo as _Foo, bar as _bar, BAZ as _BAZ, spam as _spam, eggs as _eggsif you are mirroring an entire namespace, or a god fraction of one then use a module name!import module as _modthen use _mod.Foo, etc.....Now, that may seem like a contrived example, but i've
witnessed much longer "run-on import lines" than that.I have too, but I think it's bad style -- if you are importing a LOT of names from one module, just import the darn module -- giving it a shorter name if you like. This has become a really standard practice, like:import numpy as npfor instance.The intended purpose is to: "automate the privatization of
public symbols during the import process".I'm really confused about the use case for "privatization of public symbols" at all, but again, if you need a lot of them, use the module name to prefix them. Heck give it a one character name, and then it's hardly more typing than the underscore...-CHB--
Python-ideas mailing list
Code of Conduct: http://python.org/psf/