[Python-Dev] range objects in 3.x

Benjamin Peterson benjamin at python.org
Fri Sep 23 22:26:47 CEST 2011


2011/9/23 Ethan Furman <ethan at stoneleaf.us>:
> 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.

range comparisons in 2.x have no functionality.

>
>>> 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?

I'm not sure what the history is.



-- 
Regards,
Benjamin


More information about the Python-Dev mailing list