paul rubin added the comment:
Oh nice, I didn't realize you could do that. len(range) and bool(range) (to
test for empty) also work. Ok I guess this enhancement is not needed. I will
close ticket, hope that is procedurally correct, otherwise feel free to fix.
Thanks.
--
Mark Dickinson added the comment:
> but it's messy and potentially tricky to get the actual first and last values
> of the range
Doesn't simple indexing already provide what you need here?
>>> range(1, 5, 2)[0] # first element of range
1
>>> range(1, 5, 2)[-1] # last element of range
3
New submission from paul rubin :
Inspired by a question on comp.lang.python about how to deal with an int set
composed of integers and ranges. Range objects like range(1,5,2) contain
start, stop, and step values, but it's messy and potentially tricky to get the
actual first and last values