Message313785
| Author |
serhiy.storchaka |
| Recipients |
Nofar Schnider, gvanrossum, mark.dickinson, rhettinger, serhiy.storchaka, tim.peters |
| Date |
2018-03-13.21:52:44 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1520977964.33.0.467229070634.issue33073@psf.upfronthosting.co.za> |
| In-reply-to |
|
| Content |
Wouldn't be better to add the function as_integer_ration() in the math module (or in more appropriate place)?
def as_integer_ration(x):
if hasattr(x, 'as_integer_ration'):
return x.as_integer_ration()
else:
return (x.numerator, x.denominator)
The advantage over adding the int method is that it will automatically support other rational numbers like NumPy integers. |
|