[Python-ideas] Implement comparison operators for range objects
Mike Graham
mikegraham at gmail.com
Fri Oct 14 20:28:01 CEST 2011
On Wed, Oct 12, 2011 at 1:58 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
> On Wed, Oct 12, 2011 at 6:33 PM, Steven D'Aprano <steve at pearwood.info>
> wrote:
> > I don't agree. Equality makes sense for ranges: two ranges are equal if
> they
> > have the same start, stop and step values.
>
> Hmm. I'm not sure that it's that clear cut. The other possible
> definition is that two ranges are equal if they're equal as lists.
>
For equality and comparison, this should be the standard. range objects are
sequences, and they should compare just like other sequences. If implemented
at all, equality should be that they have the same items in the same order.
If implemented at all, comparison should be lexicographic. It seems to me
you'd need a really good reason to have behavior different from every other
sequence.
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20111014/ea680b04/attachment.html>
More information about the Python-ideas
mailing list