title: The value of an empty list in function parameter, example here
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument">&ldquo;Least Astonishment&rdquo; in Python: The Mutable Default Argument</a>  </p>
  </blockquote>
  
  
  
  <pre class="lang-py prettyprint-override"><code>def f(a, L=[]):
      L.append(a)
      return L
  
  print(f(1, [1, 2]))
  print(f(1))
  print(f(2))
  print(f(3))
  </code></pre>
  
  <p>I wonder why the other f(1), f(2), f(3) has not append to the first f(1, [1,2]).
  I guess the result should be :</p>
  
  <pre><code>[1, 2, 1]
  [1, 2, 1, 1]
  [1, 2, 1, 1, 2]
  [1, 2, 1, 1, 2, 3]
  </code></pre>
  
  <p>But the result is not this. I do not know why.</p>