python: default value for function
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument">“Least Astonishment” in Python: The Mutable Default Argument</a>  </p>
</blockquote>



<p>In python tutorial, I read the following example:</p>

<pre><code>def f(a, L=[]):
    L.append(a)
    return L
print f(1)
print f(2)
print f(3)
</code></pre>

<p>This will print</p>

<pre><code>[1]
[1, 2]
[1, 2, 3]
</code></pre>

<p>I don't know why, even though default is evaluated only once, why L variable can keep the previous call's value?</p>
