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 plt
But have NEVER done the leading underscore thing...
from module import Foo as _Foo, bar as _bar, BAZ as _BAZ, spam as _spam, eggs as _eggs
if you are mirroring an entire namespace, or a god fraction of one then use a module name!
import module as _mod
then 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 np
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...