[issue42156] Currency not correct for all locales
Eric V. Smith
report at bugs.python.org
Mon Oct 26 14:58:45 EDT 2020
Eric V. Smith <eric at trueblade.com> added the comment:
And just to show that python is doing the right thing, if the locale is set up correctly, I'll show the following hack:
>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'en_US')
'en_US'
>>> locale.currency(24.99)
'$24.99'
>>> locale._override_localeconv["p_cs_precedes"] = 0
>>> locale.currency(24.99)
'24.99$'
Notice the change from '$24.99' to '24.99$' when I change p_cs_precedes to 0.
WARNING: you really, really shouldn't use _override_localeconv. It looks like it exists just for testing, but I'm using it here to show that currency formatting does respect p_cs_precedes.
On the other hand, I've often wanted to build up a locale programmatically and then use it, so maybe we should support that use case.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42156>
_______________________________________
More information about the Python-bugs-list
mailing list