title: Getting a slice of a numpy ndarray (for arbitary dimensions)
body: <p>I have a Numpy array of arbitrary dimensions, and an index vector containing one number for each dimension. I would like to get the slice of the array corresponding to the set of indices less than the value in the index array for all dimensions, e.g.</p>
  
  <pre><code>A = np.array([[1, 2, 3, 4],
                [5, 6, 7, 8],
                [9,10,11,12]])
  index = [2,3]
  
  result = [[1,2,3],
            [5,6,7]]
  </code></pre>
  
  <p>The intuitive syntax for this would be something like <code>A[:index]</code>, but this doesn't work for obvious reasons.</p>
  
  <p>If the dimension of the array were fixed, I could write <code>A[:index[0],:index[1],</code>...<code>:index[n]]</code>; is there some kind of list comprehension I could use, like <code>A[:i for i in index]</code>?</p>