[Tutor] How to extract numerator and denominator from fractions.Fraction(4, 32)?

Richard D. Moores rdmoores at gmail.com
Mon Aug 5 15:09:32 CEST 2013


On Mon, Aug 5, 2013 at 5:56 AM, Dominik George <nik at naturalnet.de> wrote:
> Hi,
>
> how about casting to str()?
>
> -nik

Thanks very much Nik. I should have tried that.

>>> from fractions import Fraction
>>> str(Fraction(6,21))
'2/7'

Dick


More information about the Tutor mailing list