In Python, why can a function modify some arguments as perceived by the caller, but not others?
<p>I'm new to Python and am trying to understand its approach to variable scope. In this example, why is <code>f()</code> able to alter the value of <code>x</code>, as perceived within <code>main()</code>, but not the value of <code>n</code>?</p>

<pre><code>def f(n, x):
    n = 2
    x.append(4)
    print 'In f():', n, x

def main():
    n = 1
    x = [0,1,2,3]
    print 'Before:', n, x
    f(n, x)
    print 'After: ', n, x

main()
</code></pre>

<p>Output:</p>

<pre><code>Before: 1 [0, 1, 2, 3]
In f(): 2 [0, 1, 2, 3, 4]
After:  1 [0, 1, 2, 3, 4]
</code></pre>
