Format a number as currency! I can't find any help on this simple problem.

Peter Otten __peter__ at web.de
Tue Oct 17 17:05:34 CEST 2006


jr wrote:

>> >>> import locale
>> >>> locale.setlocale(locale.LC_ALL, 'English_United States.1252')
>> 'English_United States.1252'

> Just tried the first 2 commands on win XP, Python 2.5 under Idle.
> An Error is raised: "unsupported locale setting" (lib/locale.py in
> setlocale, line 476).
> Actually I get the error also under Python 2.4.3
> Any idea what I'm missing?

Let your machine decide

>>> locale.setlocale(locale.LC_ALL, "")
'de_DE.UTF-8'

or try something less specific:

>>> locale.setlocale(locale.LC_ALL, "en_US")
'en_US'

Peter



More information about the Python-list mailing list