[Python-Dev] range objects in 3.x
Ethan Furman
ethan at stoneleaf.us
Fri Sep 23 22:23:26 CEST 2011
Benjamin Peterson wrote:
> 2011/9/23 Ethan Furman <ethan at stoneleaf.us>:
>>
>> 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~
More information about the Python-Dev
mailing list