title: Swapping Columns with NumPy arrays
body: <p>When I have <code>a=1</code> and <code>b=2</code>, I can write <code>a,b=b,a</code> so that <code>a</code> and <code>b</code> are interchanged with each other.</p>
  
  <p>I use this matrix as an array:</p>
  
  <pre><code>   [ 1,  2,  0, -2]
     [ 0,  0,  1,  2]
     [ 0,  0,  0,  0]
  </code></pre>
  
  <p>Swapping the columns of a numpy array does not work:</p>
  
  <pre><code>import numpy as np
  
  x = np.array([[ 1,  2,  0, -2],
     [ 0,  0,  1,  2],
     [ 0,  0,  0,  0]])
  
  x[:,1], x[:,2] = x[:,2], x[:,1]
  </code></pre>
  
  <p>It yields:</p>
  
  <pre><code>   [ 1,  0,  0, -2]
     [ 0,  1,  1,  2]
     [ 0,  0,  0,  0]
  </code></pre>
  
  <p>So <code>x[:,1]</code> has simply been overwritten and not transferred to <code>x[:,2]</code>.</p>
  
  <p>Why is this the case?</p>