New submission from Jon Clements <jon...@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)
Decimal('0.7142857142857142857142857143')

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 <rep...@bugs.python.org>
<http://bugs.python.org/issue15136>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to