title: Python: Index an array using the colon operator in an arbitrary dimension
body: <p>I have a numpy nd array. A simplified version of my task is to take a vector from along each axis. To illustrate:</p>
  
  <pre><code>import numpy
  x = numpy.array(range(24)).reshape((2,3,4))
  x0 = x[0,0,:]
  x1 = x[0,:,0]
  x2 = x[:,0,0]
  </code></pre>
  
  <p>However I do not necessarily know the number of dimensions x will have. So the challenge is how to place the colon : indexing operator in a variable location. An example of what such syntax could look like:</p>
  
  <pre><code>n = x.ndim
  ind = list(np.zeros(n))
  dim = 0
  ind[dim] = ':'
  y = x[ind]
  </code></pre>
  
  <p>or</p>
  
  <pre><code>y = indexer.index(x,ind)
  </code></pre>
  
  <p>for some module indexer. I could write it, but I feel like this must already be solved, I can't be the only one who wants to do this. In MATLAB, for example, you can do this with the subsref() function.</p>
  
  <p>Does any such construct exist in python / numpy / other module?</p>