Understanding python slicings syntax as described in the python language reference
<p>The following is the slicings syntax that I copied from <a href="https://docs.python.org/3/reference/expressions.html#slicings" rel="nofollow">The Python Language Reference</a>:</p>

<pre><code>slicing      ::=  primary "[" slice_list "]"
slice_list   ::=  slice_item ("," slice_item)* [","]
slice_item   ::=  expression | proper_slice
proper_slice ::=  [lower_bound] ":" [upper_bound] [ ":" [stride] ]
lower_bound  ::=  expression
upper_bound  ::=  expression
stride       ::=  expression
</code></pre>

<p>Per my understanding, this syntax equates to <code>SomeMappingObj[slice_item,slice_item etc...]</code> which again equates to something like <code>a[0:2:1,4:7:1]</code> and <code>a =[i for i in range(20)]</code>. </p>

<p>But, I can't test this in IPython and I did not find any questions about multiple slicings. Is my interpretation about multiple slicing in python correct? What am I doing incorrectly?</p>

<pre><code>In [442]: a=[i for i in range(20)]

In [443]: a[0:12:2]
Out[443]: [0, 2, 4, 6, 8, 10]

In [444]: a[0:12:2,14:17:1]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-444-117395d33bfd&gt; in &lt;module&gt;()
----&gt; 1 a[0:12:2,14:17:1]

TypeError: list indices must be integers or slices, not tuple
</code></pre>

<p>Note that the grammar is structured this way to allow two things:</p>

<ol>
<li><p>A family of <code>slice</code> literals:</p>

<ol>
<li><code>x:y:z == slice(x, y, z)</code></li>
<li><code>x:y == slice(x, y, None)</code></li>
<li><code>x: == slice(x, None, None)</code></li>
<li><code>x::z == slice(x, None, z)</code></li>
<li><code>::z == slice(None, None, z)</code></li>
<li><code>:y:z == slice(None, y, z)</code></li>
<li><code>:: == slice(None, None, None)</code></li>
<li><code>:y: == slice(None, y, None)</code></li>
</ol>

<p>There are a few other patterns possible (<code>x:y:</code>, <code>:y</code>, etc), but each
is a variation on one of the above.</p></li>
<li><p>Slice literals may <em>only</em> be used inside <code>[...]</code>, not in any arbitrary expression.</p></li>
</ol>

<p>Otherwise, the comma-separate list is treated like any other tuple. When you write an expression like <code>f[1, 2:3, 5::7]</code>, then <code>f.__getitem__</code> receives a tuple <code>(1, slice(2, 3, None), slice(5, None, 7)</code> as its argument. What <code>f.__getitem__</code> <em>does</em> with that argument is entirely up to <code>type(f)</code>'s implementation of <code>__getitem__</code>. For instance, lists and strings only accept <code>int</code> and <code>slice</code> values as arguments, and dicts only accept hashable values.</p>

python python-3.x slice