<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 25, 2015 at 9:47 PM, Doug Hellmann <span dir="ltr"><<a href="mailto:doug@doughellmann.com" target="_blank">doug@doughellmann.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
On Wed, Feb 25, 2015, at 02:59 PM, Robert Collins wrote:<br>
> On 26 February 2015 at 08:54, melanie witt <<a href="mailto:melwittt@gmail.com">melwittt@gmail.com</a>> wrote:<br>
> > On Feb 25, 2015, at 10:51, Duncan Thomas <<a href="mailto:duncan.thomas@gmail.com">duncan.thomas@gmail.com</a>> wrote:<br>
> ><br>
> >> Is there anybody who'd like to step forward in defence of this rule and explain why it is an improvement? I don't discount for a moment the possibility I'm missing something, and welcome the education in that case<br>
> ><br>
> > A reason I can think of would be to preserve namespacing (no possibility of function or class name collision upon import). Another reason could be maintainability, scenario being: Person 1 imports ClassA from a module to use, Person 2 comes along later and needs a different class from the module so they import ClassB from the same module to use, and it continues. If only the module had been imported, everybody can just do module.ClassA, module.ClassB instead of potentially multiple imports from the same module of different classes and functions. I've also read it doesn't cost more to import the entire module rather than just a function or a class, as the whole module has to be parsed either way.<br>
><br>
> I think the primary benefit is that when looking at the code you can<br>
> tell where a name came from. If the code is using libraries that one<br>
> is not familiar with, this makes finding the implementation a lot<br>
> easier (than e.g. googling it and hoping its unique and not generic<br>
> like 'create' or something.<br>
<br>
</span>I think the rule originally came from the way mock works. If you import<br>
a thing in your module and then a test tries to mock where it came from,<br>
your module still uses the version it imported because the name lookup<br>
isn't done again at the point when the test runs. If all external<br>
symbols are accessed through the module that contains them, then the<br>
lookup is done at runtime instead of import time and mocks can replace<br>
the symbols. The same benefit would apply to monkey patching like what<br>
eventlet does, though that's less likely to come up in our own code than<br>
it is for third-party and stdlib modules.<br></blockquote><div><br></div><div>I second Doug's analysis. I've already had a hard time figuring out why mock wasn't doing what I wanted it to do and following H302 just fixed it...<br><br></div><div>BR,<br></div><div>Simon<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Doug<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> -Rob<br>
><br>
> --<br>
> Robert Collins <<a href="mailto:rbtcollins@hp.com">rbtcollins@hp.com</a>><br>
> Distinguished Technologist<br>
> HP Converged Cloud<br>
><br>
> __________________________________________________________________________<br>
> OpenStack Development Mailing List (not for usage questions)<br>
> Unsubscribe:<br>
> <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
> <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</div></div></blockquote></div><br></div></div>