title: Mutability of Python list in a recursive algorithm
body: <p>I coded up this in-place quicksort algorithm, however the modified array is not being passed up to the parent call. I am new to Python and don't understand well the pass by value/reference, mutable/immutable stuff etc.
  Any explanation guidance would be great!</p>
  
  <pre><code>def quickSortPartition(a, l, r):
      if len(a) &lt; 2:
          return a
      else:
          print a, l, r
          p = a[l]
          i = l + 1
          for j in range(l + 1, r+1):
              if a[j] &lt; p:
                  temp = a[i]
                  a[i] = a[j]
                  a[j] = temp
                  i = i + 1
          temp = a[l]
          a[l] = a[i - 1]
          a[i - 1] = temp
          firstPartition = a[:i-1]
          pivot = a[i-1]
          secondPartition = a[i:]
          if len(a[:i-1]) &gt; 1:
              quickSortPartition(a[:i-1], 0, len(a[:i-1])-1)
          if len(a[i:]) &gt; 1:
              quickSortPartition(a[i:], 0, len(a[i:])-1)
          return a
  
  
  lines = [3, 8, 2, 5, 1, 4, 7, 6]
  
  # print lines
  quickSorted = quickSortPartition(lines, 0, len(lines)-1)
  
  print quickSorted
  </code></pre>