<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> If a function knows of the presence of a global, it's not asking too<br>
> much for it to not re-use the same name in local scope.<br>
<br>
</div>Yes.</blockquote><div><br></div><div>It's just a function wanting to act as-if it were in a different environment than its default. By that same reasoning you could state that "If a function knows of the presence of a built-in, it's not asking too much for it to not re-use the same name in local scope." Yet if rebinding "id" is such a crime, why is it so oft done? Rebinding logger locally in a function is really no different to a subclass rebinding a variable from its main class using that class' value. <b>The only difference is that, in that case, you have an alternate binding to the original value.</b></div>
<div><b><br></b></div><div><div><font face="'courier new', monospace">>>> class A():</font></div><div><font face="'courier new', monospace">... val = 1</font></div><div><font face="'courier new', monospace">... </font></div>
<div><font face="'courier new', monospace">>>> class B(A):</font></div><div><font face="'courier new', monospace">... val = str(val) # Obviously, this doesn't work</font></div><div><font face="'courier new', monospace">... </font></div>
<div><font face="'courier new', monospace"><SNIP></font></div><div><font face="'courier new', monospace">NameError: name 'val' is not defined</font></div><div><font face="'courier new', monospace">>>> class B(A):</font></div>
<div><font face="'courier new', monospace">... val = str(A.val) # But it's OK as we can just do this ^^</font></div><div><font face="'courier new', monospace">... </font></div><div><font face="'courier new', monospace">>>> B().val</font></div>
<div><font face="'courier new', monospace">'1'</font></div><div><font face="'courier new', monospace">>>> </font></div></div><div><font face="arial, helvetica, sans-serif"><br></font></div>
<div><font face="arial, helvetica, sans-serif">The only reason it's not minded with classes is because there's a good way to do it.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div>
<font face="arial, helvetica, sans-serif">I get that my analogy doesn't use globals, but the idea of extending a more-global attribute locally is shared between the concepts.</font></div></div>