title: Are there any rules for when a method changes an object "in place" or returns a new object?
body: <p>I'm practicing for my exam and there are always questions asking whether a method changes an object in place or creates a new object. I wonder if there are any general rules applied to this or if I just have to memorise the outcome for different methods? </p>
  
  <p>The examples from my exam are:</p>
  
  <pre><code>s = 'horse'
  s.upper()
  print(s)
  </code></pre>
  
  <p>this will generate <code>horse</code> and not <code>HORSE</code>, and thereby s is not changed by <code>.upper</code>, however</p>
  
  <pre><code>l = [1, 3, 2]
  l.sort()
  print(l)
  </code></pre>
  
  <p>will generate <code>[1, 2, 3]</code> and not <code>[1, 3, 2]</code>, and thereby l is changed by <code>.sort</code></p>
  
  <p>Are there any ways to differentiate between these?</p>