Python base classes share attributes?
<p>Code in test.py:</p>

<pre><code>class Base(object):
    def __init__(self, l=[]):
        self.l = l

    def add(self, num):
        self.l.append(num)

    def remove(self, num):
        self.l.remove(num)

class Derived(Base):
    def __init__(self, l=[]):
        super(Derived, self).__init__(l)
</code></pre>

<p>Python shell session:</p>

<pre><code>Python 2.6.5 (r265:79063, Apr  1 2010, 05:22:20) 
[GCC 4.4.3 20100316 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import test
&gt;&gt;&gt; a = test.Derived()
&gt;&gt;&gt; b = test.Derived()
&gt;&gt;&gt; a.l
[]
&gt;&gt;&gt; b.l
[]
&gt;&gt;&gt; a.add(1)
&gt;&gt;&gt; a.l
[1]
&gt;&gt;&gt; b.l
[1]
&gt;&gt;&gt; c = test.Derived()
&gt;&gt;&gt; c.l
[1]
</code></pre>

<p>I was expecting "C++-like" behavior, in which each derived object contains its own instance of the base class. Is this still the case? Why does each object appear to share the same list instance?</p>
