Using arguments in Python functions
<p>I'm aware of mutuable vs immutable arguments in Python, and which is which, but here is a weird issue I ran into with mutable arguments. The simplified version is as follows:</p>

<pre><code>def fun1a(tmp):
    tmp.append(3)
    tmp.append(2)
    tmp.append(1)
    return True

def fun1(a):
    b = fun1a(a)
    print a #prints [3,2,1]
    return b

def fun2a():
    tmp = []
    tmp.append(3)
    tmp.append(2)
    tmp.append(1)
    return [True, tmp]

def fun2(a):
    [b, a] = fun2a()
    print a #prints [3,2,1]
    return b

def main():
    a=[]
    if fun1(a):
        print a #prints [3,2,1]
    if fun2(b):
        print b #prints garbage, e.g. (0,1)
</code></pre>

<p>As you can see the only difference is that fun2 points the passed in argument to reference a list created inside fun2a, while fun1 simply appends to the list created in main. In the end, fun1 returns the correct result, while fun2 returns random garbage rather than the result I'd expect. What's the problem here?</p>

<p>Thanks</p>
