Formatting Currency According to Locale
piro at officine.it
Wed Apr 28 18:46:46 CEST 2004
Is there any way to make the most of locale.localeconv() in formatting currencies?
I can use many tricks as
>>> locale.setlocale(locale.LC_ALL, locale.getlocale())
>>> lc = locale.localeconv()
>>> cash = 1427.48
>>> print "%s%s" % (
locale.format('%.*f', (lc['frac_digits'],cash), 1))
But that presumes many things, such as
lc['mon_grouping'] == lc['grouping'] # format uses the latter value, doesn't he?
lc['p_sign_posn'] == 3 # else i must change the format string,
# maybe building a mapping to order the pieces, splitting + and - cases...
Python 2.3.2 (#49, Oct 24 2003, 13:37:57) [MSC v.1200 32 bit (Intel)] on win32
... and watching localeconv(), i also see many other not much documented details:
Is it up to me to write a function to keep all these details into account?
More information about the Python-list