[Python-ideas] Implement comparison operators for range objects

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Oct 13 08:39:58 CEST 2011


Guido van Rossum wrote:

> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: 'Decimal' object cannot be interpreted as an integer
> 
>>>>range(int(Decimal(10)))
> 
> range(0, 10)

It refuses to work on floats, too, even if they
happen to have integer values:

 >>> range(1.0, 10.0)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: 'float' object cannot be interpreted as an integer

If we think that's a good idea, presumably the same thing
ought to apply to Decimals. Or are Decimals supposed to be
more "exact" than floats somehow?

-- 
Greg



More information about the Python-ideas mailing list