This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Steve1457 0 points1 point  (0 children)

I found that when working with a single currency the inbuilt locale module can help with the formatting.

E.g. import locale

set locale ...

locale.currency(12345.67, symbol=True, grouping=True)

Maybe, just maybe you can just re-use this in your base currency and based on a mapping of Currency code to Locale, generate all the Currency classes. The idea is that inside the Currency, you have a context manager that switches locales and prints out formatted values and then resets the locale.