On Wed, Oct 12, 2011 at 3:57 PM, Ethan Furman email@example.com wrote:
Guido van Rossum wrote:
I beg to differ with all those who want range(0, 10, 2) == range(0, 11, 2).
I think practicality should beat purity here -- if the same results will be generated, then the ranges are the same and should be equal, no matter which exact parameters were used to create them.
Then we'd be forever stuck with not exporting the start/stop/step values. I'd much rather export those (like the slice() object does).
(IOW I find the lack of exported start/stop/step values an omission, not a feature, and would like to fix that too.)
After all the repr() shows the end point that was requested, not the end point after "normalization" (or whatever you'd call it) so the three parameters that went in should be considered state.
OTOH range(10) == range(0, 10) == range(0, 10, 1).
Because their repr() is the same: "range(0, 10)", thus proving that the internal state is the same.
For range objects, I believe that the internal state represents what theey really "mean", and the sequence of vallues generated by iterating merely follows.