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

Dominik George nik at naturalnet.de
Mon Aug 5 14:56:33 CEST 2013


Hi,

how about casting to str()?

-nik



"Richard D. Moores" <rdmoores at gmail.com> schrieb:
>>>> import fractions
>>>> fractions.Fraction(6, 21)
>Fraction(2, 7)
>
>How do I turn that Fraction(2, 7) into "1/7"? (and not
>0.2857142857142857...)
>
>Or do I have to employ fractions.gcd?
>
>I can't seem to find the answer in the doc at
><http://docs.python.org/3/library/fractions.html#module-fractions>
>
>Thanks,
>
>DIck Moores
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>To unsubscribe or change subscription options:
>http://mail.python.org/mailman/listinfo/tutor

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130805/7bc28162/attachment.html>


More information about the Tutor mailing list