<br><br><div class="gmail_quote">On Sat, Jan 9, 2010 at 9:08 PM, Lie Ryan <span dir="ltr"><<a href="mailto:lie.1296@gmail.com">lie.1296@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On 1/10/2010 11:23 AM, Eric Pavey wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I should add (that as I understand it), when you do a 'from foo import<br>
blah', or 'from foo import *', this is doing a /copy/ (effectively) of<br>
that module's attributes into the current namespace. Doing "import foo"<br>
or "import foo as goo" is keeping a /reference /to the imported module<br>
rather than a copy.<br>
</blockquote>
<br></div>
No, that's a roundabout way to look at it. Python's variable holds references to objects[1] and never the object themselves; name assignment statement in python never makes a copy of the object, but always makes a new reference to the same object. "Assignment statements" in python includes the '=', 'from import', and regular 'import' [2].<br>
<br>
[1] this is call-by-object <a href="http://effbot.org/zone/python-objects.htm" target="_blank">http://effbot.org/zone/python-objects.htm</a> <a href="http://effbot.org/zone/call-by-object.htm" target="_blank">http://effbot.org/zone/call-by-object.htm</a><br>
[2] there are other more obscure statements that is an 'assignment statement' as well, such as "with ... as ...", "agumented assignment operators", dictionary/list assignment, etc. The list is non-exhaustive.<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If you use the 'from import' system, changes made to attrs of the<br>
imported module /won't/ be seen by any other module that imported it.<br>
If you do just an 'import' on a module (or 'import ... as ...'), then<br>
changes made to attrs on the imported module /will /be seen by othe<br>
modules that import it as well. I hope that is somewhat clear. ;)<br>
</blockquote>
<br></div>
Read both links to effbot's article, they should make it clear why the current behavior is the way it is.<br></blockquote></div><br>See, I figured I'd get straightened out myself by posting that. Those concepts help me out as well ;) Always learning...<br>