title: How to raise an IndexError when slice indices are out of range?
body: <p>The <a href="https://docs.python.org/2/library/exceptions.html#exceptions.IndexError" rel="noreferrer">Python Documentation</a> states that</p>
  
  <blockquote>
    <p><em>slice indices</em> are silently truncated to fall in the <em>allowed range</em></p>
  </blockquote>
  
  <p>and therefor no <code>IndexErrors</code> are risen when slicing a list, regardless what <code>start</code> or <code>stop</code> parameters are used:</p>
  
  <pre><code>&gt;&gt;&gt; egg = [1, "foo", list()]
  &gt;&gt;&gt; egg[5:10]
  []
  </code></pre>
  
  <p>Since the list <em><code>egg</code> does not contain any indices greater then <code>2</code></em>, a <code>egg[5]</code> or <code>egg[10]</code> call would raise an <code>IndexError</code>:</p>
  
  <pre><code>&gt;&gt; egg[5]
  Traceback (most recent call last):
  IndexError: list index out of range
  </code></pre>
  
  <p>The question is now, <em>how can we raise an <code>IndexError</code>, when both given slice indices are out of range?</em></p>