title: Python - why it doesn't create a new instance of object?
body: <p>I have a little problem that I do not understand. </p>
  
  <p>I have a method:</p>
  
  <pre><code>def appendMethod(self, newInstance = someObject()):
      self.someList.append(newInstace)
  </code></pre>
  
  <p>I call this method without attributes:</p>
  
  <pre><code>object.appendMethod()
  </code></pre>
  
  <p>And actually I append the list with the same instance of someObject.</p>
  
  <p>But if I change it to:</p>
  
  <pre><code>def appendMethod(self):
      newInstace = someObject()
      self.someList.append(newInstance)
  </code></pre>
  
  <p>I get new instance of that object every time, what's the difference?</p>
  
  <p>Here's an example:</p>
  
  <pre><code>class someClass():
      myVal = 0
  
  class otherClass1():
  
      someList = []
  
      def appendList(self):
          new = someClass()
          self.someList.append(new)
  
  class otherClass2():
  
      someList = []
  
      def appendList(self, new = someClass()):
          self.someList.append(new)
  
  newObject = otherClass1()
  newObject.appendList()
  newObject.appendList()
  print newObject.someList[0] is newObject.someList[1]
  &gt;&gt;&gt;False
  
  anotherObject = otherClass2()
  anotherObject.appendList()
  anotherObject.appendList()
  print anotherObject.someList[0] is anotherObject.someList[1]
  &gt;&gt;&gt;True
  </code></pre>