title: Iterate across arbitrary dimension in numpy
body: <p>I have a multidimensional numpy array, and I need to iterate across a given dimension. Problem is, I won't know <strong>which</strong> dimension until runtime. In other words, given an array m, I could want</p>
  
  <pre><code>m[:,:,:,i] for i in xrange(n)
  </code></pre>
  
  <p>or I could want</p>
  
  <pre><code>m[:,:,i,:] for i in xrange(n)
  </code></pre>
  
  <p>etc.</p>
  
  <p>I imagine that there must be a straightforward feature in numpy to write this, but I can't figure out what it is/what it might be called. Any thoughts?</p>