[Python-ideas] Implement comparison operators for range objects
Bruce Leban
bruce at leapyear.org
Thu Oct 13 23:13:50 CEST 2011
On Thu, Oct 13, 2011 at 5:27 AM, Sven Marnach <sven at marnach.net> wrote:
>
> The *current interface* of ranges is that of a sequence and nothing
> more. The only place where the original parameters that were used to
> create the sequence pop up is in its representation. Giving those
> parameters more weight seems a bit like remembering the list
> coomprehension that was used to create a list and take this into
> account when comparing lists (of course I'm exaggerating here to make
> a point). *[emphasis added]*
>
The current interface doesn't include the changes you want to make either.
Limiting the consideration of extending the interface of ranges to exactly
your proposal is unnecessarily limiting.
Suppose we modified ranges to allow changing the step value.
>>> x = range(0,10,3)
>>> x
range(0, 10, 3)
>>> x.set_step(2)
range(0, 10, 2)
Now I'm not saying we *should* allow you to change the step value but we
*could*. And if we did that then, the original stop value definitely
matters. Making the decision now to ignore that value when comparing for
equality means that we preclude other features in the future.
--- Bruce
Follow me: http://www.twitter.com/Vroo http://www.vroospeak.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20111013/fb127976/attachment.html>
More information about the Python-ideas
mailing list