Why not FP for Money?
Aahz
aahz at pythoncraft.com
Thu Sep 23 15:08:53 EDT 2004
In article <mailman.3781.1095942759.5135.python-list at python.org>,
Carlos Ribeiro <carribeiro at gmail.com> wrote:
>
>PEP327 also does mention it:
>
>http://www.python.org/peps/pep-0327.html#explicit-construction:
>"""
>So, the accepted solution through c.l.p is that you can not call
>Decimal with a float.
>"""
>
>So, in order to construct a Decimal, I need to write something like:
>
>>>> a = decimal.Decimal('35.72')
>>>> b = decimal.Decimal('1.73')
>>>> a+b
>Decimal("37.45")
Not sure of precise syntax (haven't tried 2.4 yet), but this should
work:
a = decimal.from_float(35.72)
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"A foolish consistency is the hobgoblin of little minds, adored by little
statesmen and philosophers and divines." --Ralph Waldo Emerson
More information about the Python-list
mailing list