Weird Problem with Classes and Optional Arguments
<p>Okay so this was driving me nuts all day. </p>

<p>Why does this happen:</p>

<pre><code>class Foo:
    def __init__(self, bla = {}):
        self.task_defs = bla
    def __str__(self):
        return ''.join(str(self.task_defs))

a = Foo()
b = Foo()
a.task_defs['BAR'] = 1
print 'B is ==&gt; %s' % str(b)
print 'A is ==&gt; %s' % str(a)
</code></pre>

<p>Gives me the output:</p>

<pre><code>B is ==&gt; {'BAR': 1}
A is ==&gt; {'BAR': 1}
</code></pre>

<p>I know it has to do with python passing everything by reference.</p>

<p>But why does this happen? This was literally making me go insane all day, basically causing me to tear my stuff apart. Shouldn't python be smart enough to deal with something like this?</p>
