[issue28716] Fractions instantiation revisited

Eric Wieser report at bugs.python.org
Sun Nov 5 18:21:38 EST 2017


Eric Wieser <wieser.eric+pybug at gmail.com> added the comment:

> allows Fraction instantiation from duck-typing classes that provide as_integer_ratio

This would allow the numpy `np.floating` types to take part in `Fraction` conversion as well, which would be great.

As far as I can tell, `Decimal` already follows this duck-typing, so it would be a shame for other modules not to.

Perhaps an `num, den = operator.rational(x)` is needed to unify this code across the places that coerce rational numbers.

----------
nosy: +Eric.Wieser

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue28716>
_______________________________________


More information about the Python-bugs-list mailing list