Does it have something to do with:<br><a href="http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm">http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm</a><br><br>And if so can anyone explain it a bit for me, I'm being slow tonight.
<br><br>I thought each class got it's own namespace and this sharing of mutable objects is confusing me.<br><br>Thanks.<br><br><br><div class="gmail_quote">On Jan 21, 2008 9:16 PM, John Morris <<a href="mailto:jrmorrisnc@gmail.com">
jrmorrisnc@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">class Foo:<br> '''Represents a foo'''
<br> def __init__(self, name):<br> '''Initializes the person's data'''<br> <a href="http://self.name" target="_blank">self.name</a> = name<br>
print '(Initializing %s)' % <a href="http://self.name" target="_blank">self.name</a><br> self.ot = Bar(<a href="http://self.name" target="_blank">self.name</a>)<br> print '(After Other - %s)' %
<a href="http://self.name" target="_blank">self.name
</a><br><br>class Bar:<br> def __init__(self, name):<br> <a href="http://self.name" target="_blank">self.name</a> = name<br> print 'Other', <a href="http://self.name" target="_blank">self.name</a>
<br> self.name.pop('srv')
<br> print 'Other (Changed)', <a href="http://self.name" target="_blank">self.name</a><br><br>dict = { "srv" : "why", "goo" : "sticky" }<br>foo = Foo(dict)<br>print
<a href="http://foo.name" target="_blank">
foo.name</a><br><br><br>Why does the pop in the Bar class nuke the srv k & v from <a href="http://Foo.name" target="_blank">Foo.name</a> as well?<br><br>
</blockquote></div><br><br clear="all"><br>-- <br>John Morris<br><a href="mailto:jrmorrisnc@gmail.com">jrmorrisnc@gmail.com</a><br>"Do nothing which is of no use." -- Miyamoto Musashi<br><a href="<a href="http://profile.mygamercard.net/nerdality">
http://profile.mygamercard.net/nerdality</a>"><br><img src="<a href="http://card.mygamercard.net/gbar/abyss/nerdality.gif">http://card.mygamercard.net/gbar/abyss/nerdality.gif</a>" border=0><br></a>