Message313785
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. |
|
Date |
User |
Action |
Args |
2018-03-13 21:52:44 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, tim.peters, rhettinger, mark.dickinson, Nofar Schnider |
2018-03-13 21:52:44 | serhiy.storchaka | set | messageid: <1520977964.33.0.467229070634.issue33073@psf.upfronthosting.co.za> |
2018-03-13 21:52:44 | serhiy.storchaka | link | issue33073 messages |
2018-03-13 21:52:44 | serhiy.storchaka | create | |
|