title: Mutability (?) of a list in python keyword argument
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument">“Least Astonishment” in Python: The Mutable Default Argument</a>  </p>
  </blockquote>
  
  
  
  <p>I am not sure what this is called, and thus have had difficulties finding documentation for what is going on. I was hoping someone here might be able to point me in the right direction.</p>
  
  <p>In the following example, where I have a list as a default value for a keyword argument, it behaves in a way I was not expecting:</p>
  
  <pre><code>class A(object):
      def __init___(self, c=[0,0]):
          self.c = c
  
  class B(A):
      def __init__(self):
          super(B, self).__init__()
  
  a = A()
  b = B()
  
  print a.c, b.c  # outputs [0, 0] [0, 0]
  
  a.c[1] = 5
  
  print a.c, b.c  # outputs [0, 5] [0, 5]
  </code></pre>
  
  <p>I understand that lists are mutable, but I had assumed that in the case of using a list as a default keyword argument, a 'new' list would be created each time. Is there documentation explaining why this is not the case?</p>