compare range objects

Ethan Furman ethan at stoneleaf.us
Thu Oct 20 14:24:53 EDT 2011


Ian Kelly wrote:
> On Thu, Oct 20, 2011 at 12:00 PM, Hans Mulder <hansmu at xs4all.nl> wrote:
>>> There's already a discussion about this on python-ideas.  But somebody
>>> please tell me, why would you ever need to compare ranges?
>> It could be useful if you're unit-testing a function that returns a range.
> 
> Easy:
> 
> list(range1) == list(range2)

The biggest reason in my mind for implementing range equality is that 
currently two ranges compare equal iff they are the same range.  In 
other words:

--> range(10) == range(10)
False

~Ethan~



More information about the Python-list mailing list