This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author wolma
Recipients wolma
Date 2015-04-16.20:06:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
numbers.Rational defines __float__ like this:

def __float__(self):
    """float(self) = self.numerator / self.denominator

    It's important that this conversion use the integer's "true"
    division rather than casting one side to float before dividing
    so that ratios of huge integers convert without overflowing.

    return self.numerator / self.denominator

This assumes that division of two Integral numbers returns a float, which the numbers ABC does not enforce in any way.
IMO, the only logical assumption is that division of any two Integral or Rational numbers gives a Real, for which the ABC guarantees a __float__ method in turn.
So I think Rational.__float__ should

return float(self.numerator / self.denominator)
Date User Action Args
2015-04-16 20:06:57wolmasetrecipients: + wolma
2015-04-16 20:06:57wolmasetmessageid: <>
2015-04-16 20:06:57wolmalinkissue23975 messages
2015-04-16 20:06:57wolmacreate