title: Python array slicing -- How can 2D array slicing be implemented?
body: <p>I am wondering how 2D array slicing can be implemented in Python?</p>
  
  <p>For example, </p>
  
  <p><code>arr</code> is an instance of a self-defined class 2D array.</p>
  
  <p>if I want to enable 2D slicing syntax on this object like this:</p>
  
  <pre><code>arr[:,1:3] #retrieve the 1 and 2 column values of every row
  </code></pre>
  
  <p>or</p>
  
  <pre><code>arr[,:3] #retrieve the 1 and 2 column values of every row
  </code></pre>
  
  <p>The usage and syntax is just like numpy.array. But how can this kind of functionality be realized on our own?</p>
  
  <p><strong>PS:</strong></p>
  
  <p>What I have in mind:</p>
  
  <p>for the first case, the <code>[:,1:3]</code> part is like a tuple of two slices</p>
  
  <p>However, for the second case <code>[,1:3]</code> appears to be quite mysterious.</p>