[Python-Dev] range objects in 3.x

Guido van Rossum guido at python.org
Fri Sep 23 20:23:07 CEST 2011


Also, Ethan, I hope you're familiar with the reason why there is no
range() support for floats currently? (Briefly, things like range(0.0,
0.8, step=0.1) could include or exclude the end point depending on
rounding, which makes for troublesome semantics.)

On Fri, Sep 23, 2011 at 11:14 AM, Benjamin Peterson <benjamin at python.org> wrote:
> 2011/9/23 Ethan Furman <ethan at stoneleaf.us>:
>> A question came up on StackOverflow about range objects and floating point
>> numbers.  I thought about writing an frange that did for floats what range
>> does for ints, so started examining the range class.  I noticed it has
>> __le__, __lt__, __eq__, __ne__, __ge__, and __gt__ methods.  Some
>> experiments show that xrange in 2.x does indeed implement those operations,
>> but in 3.x range does not (TypeError: unorderable types: range() > range()).
>>
>> Was this intentional, or should I file a bug report?  (I was unable to find
>> anything in the What's New documents; also, I did not test in 3.0, just in
>> 2.7, 3.1, 3.2.)
>
> That's simply a consequence of everything having comparisons defined
> in 2.x. The comparison is essentially meaningless.
>
>
> --
> Regards,
> Benjamin
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
>



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


More information about the Python-Dev mailing list