What *really* are the default slice indices in Python?
<p>From the python documentation <a href="http://docs.python.org/tutorial/introduction.html#strings">docs.python.org/tutorial/introduction.html#strings</a>:</p>

<blockquote>
  <p>Slice indices have useful defaults; an omitted first index defaults to zero, an omitted second index defaults to the size of the string being sliced.</p>
</blockquote>

<p>For the standard case, this makes a lot of sense:</p>

<pre><code>&gt;&gt;&gt; s = 'mystring'
&gt;&gt;&gt; s[1:]
'ystring'
&gt;&gt;&gt; s[:3]
'mys'
&gt;&gt;&gt; s[:-2]
'mystri'
&gt;&gt;&gt; s[-1:]
'g'
&gt;&gt;&gt; 
</code></pre>

<p>So far, so good. However, using a negative step value seems to suggest slightly different defaults:</p>

<pre><code>&gt;&gt;&gt; s[:3:-1]
'gnir'
&gt;&gt;&gt; s[0:3:-1]
''
&gt;&gt;&gt; s[2::-1]
'sym'
</code></pre>

<p>Fine, perhaps if the step is negative, the defaults reverse. An ommitted first index defaults to the size of the string being sliced, an omitted second index defaults to zero:</p>

<pre><code>&gt;&gt;&gt; s[len(s):3:-1]
'gnir'
</code></pre>

<p>Looking good!</p>

<pre><code>&gt;&gt;&gt; s[2:0:-1]
'sy'
</code></pre>

<p>Whoops. Missed that 'm'. </p>

<p>Then there is everyone's favorite string reverse statement. And sweet it is:</p>

<pre><code>&gt;&gt;&gt; s[::-1]
'gnirtsym'
</code></pre>

<p>However:</p>

<pre><code>&gt;&gt;&gt; s[len(s):0:-1]
'gnirtsy'
</code></pre>

<p>The slice never includes the value of the second index in the slice. I can see the consistency of doing it that way. </p>

<p>So I think I am beginning to understand the behavior of slice in its various permutations. However, I get the feeling that the second index is somewhat special, and that the default value of the second index for a negative step can not actually be defined in terms of a number.</p>

<p>Can anyone concisely define the default slice indices that can account for the provided examples? Documentation would be a huge plus.</p>
