[issue23975] numbers.Rational implements __float__ incorrectly

Paul Moore report at bugs.python.org
Mon Apr 20 14:50:26 CEST 2015


Paul Moore added the comment:

Is it not reasonable to simply say that implementations of numbers.Rational which allow the numerator and denominator to have types for which true division doesn't return a float, have to provide their own implementation of __float__()?

It's certainly less convenient, and probably surprising for users, but the alternative is trying to work around broken integer types - after all numbers.Complex.__truediv__ says "Should promote to float when necessary" in the docstring, which to me says that a type where a/b doesn't return a float doesn't conform to the numeric tower.

----------
nosy: +paul.moore

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23975>
_______________________________________


More information about the Python-bugs-list mailing list