Re: [Python-Dev] range objects in 3.x
Benjamin Peterson wrote:
2011/9/23 Ethan Furman
: Follow-up question: since the original range returned lists, and comparisons do make sense for lists, should the new range also implement them?
What would be the use-case?
The only reason I'm aware of at the moment is to prevent loss of functionality from 2.x range to 3.x range. I'm -0 with a decision to not have range be orderable; but I understand there are bigger fish to fry. :) My original concern was that the comparison methods were there at all, but looking around I see object has them, so it makes sense to me now. I had thought I would have to implement them if I went ahead with an frange (for floats).
I note that it does implement __contains__, __getitem__, count, and index in the same way that list does.
That's because it implements the Sequence ABC.
So the question becomes, Why does it implement the Sequence ABC? Because the original range returned a list and those operations made sense? ~Ethan~
participants (6)
-
"Martin v. Löwis"
-
Antoine Pitrou
-
Benjamin Peterson
-
Ethan Furman
-
Greg Ewing
-
Guido van Rossum