[Python-ideas] Implement comparison operators for range objects

Ethan Furman ethan at stoneleaf.us
Fri Oct 14 22:58:44 CEST 2011


Guido van Rossum wrote:
> On Fri, Oct 14, 2011 at 1:10 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> A range is a sequence -- why should identical sequences not compare equal?
> 
> There's no such convention anywhere in Python. (1, 2) != [1, 2].
> collections/abc.py does not define __eq__ for sequences.

Okay, add in 'of the same type'.


> Have you personally written code that compares ranges?

I have not.  Nevertheless, I expect a sequence object of type SomeType 
that returns the identical items, in the same order,  as another 
sequence object of type SomeType to compare equal to that other sequence 
object no matter how the two objects happened to be created.

~Ethan~



More information about the Python-ideas mailing list