python of xlwings, I don't understand one of rule
<p>I could understand clearly the <code>rng[0, 0]</code> and <code>rng[1]</code>, but why? Why <code>rng[:, 3:]</code> slicing to be <code>$D$1:$D$5</code>? And why <code>rng[1:3, 1:3]</code> to be <code>$B$2:$C$3</code>, I cannot understand the rule of slicing. </p>

<pre><code>Range indexing/slicing
Range objects support indexing and slicing, a few examples:

rng = xw.Book().sheets[0].range('A1:D5')
</code></pre>

<p>I'll give it a go. Because in square brackets, indexing starts at <code>0</code> *. So for a 1-based indexing system, consider [1:3, 1:3] as (2:4, 2:4). Also bear in mind that the value after <code>:</code> is not included, so inclusively (2:4, 2:4) is (2:3, 2:3). The second Excel Column is B, the third C, and the second Excel row is 2 and the third 3. Hence the range is B2:C3.</p>

<p>IMO a horrible choice of example!  </p>

<p>Given a range A1:D5, slicing with rng[:, 3:] means all rows and fourth column to end column, hence D1:D5.</p>

<p>Taking just the column element [1:3] from the same range (A1:D5). The slicing starts (including) the second index element (0 first, 1 second) ie <code>B</code> and continues to immediately before the fourth index element (A, B, C, <code>D</code>). Hence B:C.  </p>

<p><a href="http://i.stack.imgur.com/dGR6Z.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/dGR6Z.jpg" alt="SO39226421 example"></a></p>

<p><code>*</code> For <em>why</em> start at <code>0</code> there are details <a href="http://stackoverflow.com/questions/7320686/why-does-the-indexing-start-with-zero-in-c">here</a>.</p>

python excel xlwings