[Python-ideas] Implement comparison operators for range objects

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Oct 12 20:04:27 CEST 2011


On Wed, Oct 12, 2011 at 1:58 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
..
> Should range(0, 10, 2) and range(0, 9, 2) be considered equal, or not?

I was going to ask the same question.  I think ranges r1 and r2 should
be considered equal iff list(r1) == list(r2).  This is slightly harder
to implement than just naively comparing (start, stop, step) tuples,
but the advantage is that people won't run into surprises when they
port 2.x code where result of range() is a list.



More information about the Python-ideas mailing list