Label format not the same as Data Table value

I have just had a peculiar output on a repeating panel row label. The data is populated from a Data Table (a number column saved to 2 decimals places as it is a dollar value).
When formatting the label it comes out as a decimal with a lot more than 2 decimal places (see image below)
.
The label is bound to "$"+str(self.item['foo'])

image

I suspect it is something to do with how I was binding the label.

Doing the following:
"$%.2f" % self.item['foo']

Produces the expected result:

image

This is the good old problem of storing monetary values as floats. Personally, I always avoid this by using integers and storing the value in e.g. cents rather than dollars.

3 Likes

Stripe does this, too.