title: how default arguments work in python
body: <p>I have just read an article: <a href="https://www.toptal.com/python/top-10-mistakes-that-python-programmers-make" rel="nofollow">The 10 Most Common Mistakes That Python Developers Make</a>. The problem #1 still puzzled me a lot. I will describe my problem with the codes below.</p>
  
  <pre><code>&gt;&gt;&gt;def foo(bar=[]):
  ...    bar.append("baz")
  ...    return bar
  &gt;&gt;&gt; foo()
  ["baz"]
  &gt;&gt;&gt; foo()
  ["baz", "baz"]
  </code></pre>
  
  <p>It not works, the answer in the article says list is an multable type and the default value changes during the call.But when I try this one </p>
  
  <pre><code>def foo(bar=[]):
      if bar == []:bar=[]
  ...
  </code></pre>
  
  <p>it works, so what makes the difference?</p>