[New-bugs-announce] [issue15136] Decimal accepting Fraction

Jon Clements report at bugs.python.org
Fri Jun 22 13:51:52 CEST 2012

New submission from Jon Clements <joncle at googlemail.com>:

I'm not a numeric expert but I was looking at a post on S/O which related to converting a Fraction to a certain amount of decimal places. I've had a hunt on the tracker but couldn't find anything relevant, but if I've missed it, I apologise.

# F=Fraction, D=Decimal classes

If I try num = D( F(5, 7) )

I get: TypeError: Cannot convert Fraction(5, 7) to Decimal

So I do:

>>> D(f.numerator) / D(f.denominator)

Which I think is the correct result?

I guess my question is - should Decimal do this implicitly for Fraction?

components: Library (Lib)
messages: 163397
nosy: joncle
priority: normal
severity: normal
status: open
title: Decimal accepting Fraction
type: enhancement

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list