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

Jim Mooney cybervigilante at gmail.com
Tue Aug 6 05:50:16 CEST 2013


On 5 August 2013 06:09, Richard D. Moores <rdmoores at gmail.com> wrote:
> On Mon, Aug 5, 2013 at 5:56 AM, Dominik George <nik at naturalnet.de> wrote:
>> Hi,
>>
>> how about casting to str()?

Or, to make it even more usable and get numbers back:

f = [int(x) for x in str(fractions.Fraction(6,21)).split('/')]
[2, 7]

Jim


More information about the Tutor mailing list