I have a bunch of Decimal objects. I want to test each one to see if it ends in .43. I can do this by first converting it to a string:
>>> num = Decimal('1.43')
>>> str(num).endswith('.43')
True
But that fails if I don't know what precision the Decimal was created with.
>>> num = Decimal('1.4300')
>>> str(num).endswith('.43')
False
I could do the string conversion and check if it contains .43.
>>> num = Decimal('1.4300')
>>> '.43' in str(num)
True
But that also matches other values, which I don't want.
>>> num = Decimal('1.4321')
>>> '.43' in str(num)
True
How can I check if the decimal ends in .43, with any number of trailing zeroes?