Python: Instance attribute unexpectedly loaded
<p>I learned Python last year, and was just getting back into it with a new project. I've hit a snag right at the beginning, and after a bunch of poring through documentation I'm still stumped. I have to believe it's something simple, but I can't find it. Here's the issue:</p>

<p>I have the following set up in a file:</p>

<pre><code>class Wrapper(object):
    def __init__(self, title=None):
        self.header = Thing("HEADER")
        if title is not None:
            self.header.content.append( Thing("TITLE", content=[str(title)]) )
        self.body = Thing("BODY")
        self.content = Thing("COMPLETE", content=[self.header, self.body])

class Thing(object):
    def __init__(self, name, content=[]):
        self.name = name
        self.content = content
</code></pre>

<p>Then from an interactive prompt I do:</p>

<pre><code>&gt;&gt;&gt; import things
&gt;&gt;&gt; a = things.Wrapper("This is a title")
</code></pre>

<p>Now, I would expect at this point that the <code>body</code> attribute of <code>a</code> would be a <code>Thing</code> instance with the name <code>"BODY"</code> and a <code>content</code> consisting of an empty list. What I'm surprised to find is that its <code>content</code> is actually a list containing the same <code>"TITLE"</code> instance that <code>a.header.content</code> holds.</p>

<pre><code>&gt;&gt;&gt; a.header.name
'HEADER'
&gt;&gt;&gt; a.header.content
[&lt;test.Thing object at 0xb752290c&gt;]
&gt;&gt;&gt; a.body.name
'BODY'
&gt;&gt;&gt; a.body.content
[&lt;test.Thing object at 0xb752290c&gt;]
&gt;&gt;&gt; a.body.content[0].name
'TITLE'
&gt;&gt;&gt; a.body.content[0].content
['This is a title']
</code></pre>

<p>I can't for the life of me figure out how <code>a.body.content</code> got assigned that way. Can anyone shed some light on this?</p>
