You make an interesting point. I would like to expand on it.
Suppose s is scalar and v is a list regarded as a vector. As in
usual vector arithmetic define s * v to be the list, i.e. vector,
whose i-th element is s * v[i].
Then the existing range() function in Python enjoys the following
pleasing proportionality property:
s * range(m, n, k) = range(s * m, s * n, s * k)
for all non-zero values of s including negative values.
The definition that I had proposed is the same as the existing
range() for positive steps and by definition obeys the following
identity which allows it to be extended to negative steps:
range(m, n, -k) = range(n, m, k).reverse()
With the existing range(), the formula for s * range() as a
range() is simple even if s<0 but the formula for
range().reverse() as a range() is complex.
In my proposed formula, the formula for range().reverse() as a
range() is simple but the formula for s * range() as a range is
complex if s<0.
Its a judgement call as to whether range() should behave nicely
under proportionality or reversal since it appears that it won't
behave nicely under both.
I have to admit that I prefer the proportionality identity which
means that range() would stay as it is.
Getting back to the original example, I guess the moral of the
story is that if one wants to elegantly express backwards
iteration over list indices one should use the idiom:
for i in range(len(a)).reverse():
Lou
P.S. Note how the above discussion required APL-like vector
multiplication to state the proportionality property even in
this apparently not heavily mathematical setting!
-- Lou Kates, louk@research.teleride.on.ca