You of course know that Python slices are awesome: a = 'ABCDEFG' a[:3] -> 'ABC' a[2:5] -> 'CDE' And more interestingly: a[-3:] -> 'EFG' and a[6:4:-1] -> 'GF' But you can see that the reverse slicing is starting to stretch the fence-post we are familiar with. Python uses zero based, inclusive-exclusive indexing. This corresponds to a C syntax of (for i = n; i . When you reverse it the slice goes (for i = m - 1; i > n - 1; i--) . As you can imagine this starts to get ugly and at one point it gets to be wrong: Say, as is often the case, you are not taking static, pre-determined slices but rather slices determined at runtime. Say you are taking slices between n and m or [n, m) . The forward slice is a[n:m] The backward slice is a[m-1:n-1:-1] right? Because of the fence posts? Well yes, except what happens when n = 0 ? The forward slice is fine but the reverse slice resolves to a[m-1:-1:-1] This is where Python be...
I've moved to kaushikghose.wordpress.com