howto format currency string?

Peter Otten __peter__ at web.de
Fri Aug 29 15:38:06 CEST 2003


Alex Martelli wrote:

>>>> import locale
>>>> locale.setlocale(locale.LC_ALL,('en','ascii'))
> 'en_US.ISO8859-1'


Python 2.3 (#1, Jul 30 2003, 11:19:43)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, ('de', None))
'de_DE.ISO8859-1'

It works :-)
And I always trusted the documentation/error message:

>>> locale.setlocale(locale.LC_ALL, 'de')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "locale.py", line 381, in setlocale
    return _setlocale(category, locale)
locale.Error: locale setting not supported
>>>

The second (not working) variant is taken directly from the documentation.
The error message led me to assume that my version of Python didn't support
locale setting at all.

Maybe I should file a bug report?

Peter





More information about the Python-list mailing list