On Sun, May 22, 2016, at 10:58, Marko Rauhamaa wrote: > Scheme has the best of both worlds: > > scheme@(guile-user)> 2/3 > $1 = 2/3 > scheme@(guile-user)> (exact->inexact $1) > $2 = 0.6666666666666666
Why shouldn't Python do this? Imagine some future version of Python: >>> x = 2/3 >>> x (2/3) >>> type(x) <class 'rational'> # if it's going to be so integrated into the language it's # hardly sensible to keep calling it 'fractions.Fraction' >>> float(x) 0.6666666666666666 On Sun, May 22, 2016, at 11:52, Jon Ribbens wrote: > No, it *adheres* to the principle of least surprise. Floats appearing > out of nowhere is surprising. Python 2's behaviour adhered to the > principle, and Python 3's breaks it. Disregarding for the moment the particular imperfections of the float representation (which would be gone if we used Fraction instead), this is only true if the concrete types of results are regarded as part of the result rather than as an implementation detail for how best to return the requested value. I think it would be entirely reasonable for Fractions to not only appear out of nowhere, but to *disappear* when an operation on them yields a value which is an integer. Values are more important than types. Types are less important than values. -- https://mail.python.org/mailman/listinfo/python-list