I'm looking for a method which takes a decimal.Decimal object x
and returns a string s
, such that:
x == Decimal(s)
re.match("^-?(0|[1-9][0-9]*)(.[0-9]*[1-9])?$", s) is not None
s != '-0'
In other words, the method doesn't change the value of the Decimal object; it returns a string representation which is never in scientific notation (e.g. 1e80
), and never has any trailing zeros.
I would assume there is a standard library function which lets me do that, but I haven't found any. Do you know of any?