<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 16, 2016 at 6:52 PM, Rick Johnson <span dir="ltr"><<a href="mailto:rantingrickjohnson@gmail.com" target="_blank">rantingrickjohnson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><span style="font-family:'courier new',monospace"><span class="">> Besides, why is "import x as _x" so special to require special syntax? <br></span></span></div></blockquote><div><br></div><div>It's not :-) I know I do, for instance,</div><div><br></div><div>from matplotlib  import pylot as plt</div><div><br></div><div>But have NEVER done the leading underscore thing...</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><span style="font-family:'courier new',monospace"> from module import Foo as _Foo, bar as _bar, BAZ as _BAZ, spam as _spam, eggs as _eggs<br></span></div></blockquote><div><br></div><div>if you are mirroring an entire namespace, or a god fraction of one then use a module name!</div><div><br></div><div>import module as _mod</div><div><br></div><div>then use _mod.Foo, etc.....</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><span style="font-family:'courier new',monospace">Now, that may seem like a contrived example, but i've<br>witnessed much longer "run-on import lines" than that.</span></div></blockquote><div><br></div><div>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:</div><div><br></div><div>import numpy as np</div><div><br></div><div>for instance.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><span style="font-family:'courier new',monospace">The intended purpose is to: "automate the privatization of<br>public symbols during the import process".</span></div></blockquote><div><br></div>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...</div><div class="gmail_quote"><br></div><div class="gmail_quote">-CHB</div><div class="gmail_quote"><br></div><div><br></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>