[Python-ideas] Make range objects orderable

David Blaschke dwblas at gmail.com
Fri Apr 24 00:44:50 CEST 2015


f you don't mind converting to a set (can alter the order but the
original range can be easily reproduced) then
print set(range(0, 10, 3)).issubset(set(range(10)))

On 4/23/15, Ian Cordasco <graffatcolmingov at gmail.com> wrote:
> On Thu, Apr 23, 2015 at 5:21 PM, Riley Banks <waultah at gmail.com> wrote:
>
>> I propose adding the ability to compare range objects using methods (e.g.
>> range.issubrange) and/or regular operators. Example:
>>
>>     In [56]: range(0, 10, 3).issubrange(range(10))
>>     Out[56]: True
>>
>>     In [57]: range(0, 10, 3) <= range(10)
>>     Out[57]: True
>>
>>     In [58]: range(10) <= range(0, 10, 3)
>>     Out[58]: False
>>
>> I'll write a patch if you decide that this idea is worth implementing.
>>
>
> Could you give some examples of how or when this is necessary and why you
> need it?
>
> Cheers,
> Ian
>


-- 
With the simplicity of true nature, there shall be no desire.
Without desire, one's original nature will be at peace.
And the world will naturally be in accord with the right Way.  Tao Te Ching


More information about the Python-ideas mailing list