title: Implementing slicing in __getitem__
body: <p>I am trying to implement slice functionality for a class I am making that creates a vector representation.</p>
  
  <p>I have this code so far, which I believe will properly implement the slice but whenever I do a call like <code>v[4]</code> where v is a vector python returns an error about not having enough parameters. So I am trying to figure out how to define the <code>getitem</code> special method in my class to handle both plain indexes and slicing.</p>
  
  <pre><code>def __getitem__(self, start, stop, step):
      index = start
      if stop == None:
          end = start + 1
      else:
          end = stop
      if step == None:
          stride = 1
      else:
          stride = step
      return self.__data[index:end:stride]
  </code></pre>