[Python-ideas] Implement comparison operators for range objects

Guido van Rossum guido at python.org
Thu Oct 13 20:18:10 CEST 2011


On Thu, Oct 13, 2011 at 11:08 AM, Yuval Greenfield
<ubershmekel at gmail.com> wrote:
> +1 for refusing the temptation to guess.
>
> Both equality definitions don't seem obvious or handy enough to be favorited
> by python. That is until some prevalent use cases are presented.

Ah, but the stricter equality definition (by start/stop/step) also
refuses to guess! It doesn't consider range(0, 0) and range(1, 1) as
equivalent because, indeed, it would have to guess. But it will
consider range(1) == range(1) since everybody considers those
equivalent so there's no guess-work involved. The identity-based
__eq__ does nobody any good.

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list