James Mills wrote:

There is a much easier more consistent way:

import locale
locale.setlocale(locale.LC_ALL, "en_AU.UTF-8")
'en_AU.UTF-8'

doesn't work on all Python platforms, though:

>>> locale.setlocale(locale.LC_ALL, "en_AU.UTF-8")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python25\lib\locale.py", line 478, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

and is likely to give you somewhat unpredictable output if you use the machine's actual locale:

>>> import os
>>> locale.setlocale(locale.LC_ALL, os.environ["LANG"])
'sv_SE.UTF-8'
>>> locale.format("%0.2f", 5000000, True)
'5000000,00'

</F>

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to