Daniel Lescohier added the comment:
I had other code to check scale, but you are right, I should use
quantize. There is certainly a lot to absorb in the IBM decimal
specification. I really appreciate you pointing me to quantize and
Inexact. I guess I inadvertently used the issue tracker for
Raymond Hettinger added the comment:
FWIW, there is a public API to get at the same information:
Decimal.as_tuple().
That being said, I don't see how your len(value._int) test could be
correct. The exponent will potentially shift the value way
out-of-bounds for a database. Consider Decimal('
New submission from Daniel Lescohier :
I would like to get the decimal precision of decimal.Decimal objects
(for my application, in order to validate whether a Decimal value will
fit in the defined decimal precision of a database field). The way I
found to get it was with:
precision = len(val