On Wed, 12 Oct 2011 20:18:50 -0700
Guido van Rossum
The open question so far is: How do we want our ranges to work? My intuition is weak, but says: range(0) != range(1, 1) != range(1, 1, 2) and range(0, 10, 2) != range(0, 11, 2); all because the arguments (after filling in the defaults) are different, and those arguments can come out using the start, stop, step attributes (once we implement them :-).
My intuition is contrary, but I think it comes down to: what is the use case for comparison ranges?
PS. An (unrelated) oddity with range and Decimal:
range(Decimal(10)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'Decimal' object cannot be interpreted as an integer range(int(Decimal(10))) range(0, 10)
So int() knows something that range() doesn't. :-)
Same as floats:
int(1.0) 1 range(1.0, 2, 1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'float' object cannot be interpreted as an integer
I thought it was by design? Regards Antoine.