cdecimal.Decimal v. decimal.Decimal

Skip Montanaro skip.montanaro at gmail.com
Tue Jun 20 16:49:13 EDT 2017


I'd not used the Decimal classes before, but some data I was receiving
from a database via pyodbc came that way. In writing some test cases,
I had a hard time making things work out. I eventually figure out what
was going on:

>>> import decimal, cdecimal
>>> decimal.Decimal('2226.48') == cdecimal.Decimal('2226.48')
False

(apologies for any typos, can't copy/paste)

This seems odd to me. I'm currently unable to make the comparison in
my Python 3 env (Conda woes), but I have both decimal and cdecimal in
my Python 2.7 env. Shouldn't these beasts compare equal?

Thx,

Skip



More information about the Python-list mailing list