range syntax
Colin J. Williams
cjw at sympatico.ca
Fri Nov 10 09:48:52 EST 2006
One of the little irritants of Python is that the range syntax is rather
long-winded:
[Dbg]>>> range(3, 20, 6)
[3, 9, 15]
[Dbg]>>>
It would be nice if one could have something like 3:20:6.
I've just come across the r_class in numpy which doesn't go that far
but does provide a generalization of the above:
[Dbg]>>> r_[1:6:2, 6:8, (10, 11, 13), [20,25]]
array([ 1, 3, 5, 6, 7, 10, 11, 13, 20, 25])
[Dbg]>>>
Colin W.
More information about the Python-list
mailing list