FormattingΒΆ
You can print Money
object as follows:
>>> from moneyed.l10n import format_money
>>> format_money(Money(10, 'USD'), locale='en_US')
'$10.00'
Note that you need to specify locale
or you will get the system default,
which will probably not be what you want. For this reason, it is recommended to
always provide the locale
argument, and you may well want to add your own
wrappers around this function to supply your project specific defaults.
This function is a thin wrapper around babel.numbers.format_currency. See those docs for other arguments that can be specified to control the formatting of the number. By default, Babel will apply definitions of how to format currencies that have been derived from the large CLDR database.
If you do str()
on a Money
object, you will get the same behaviour as
format_money()
, but with no options supplied, so you will get the system
default locale.