Changing the decimal separator to a comma
From: andyj (andrew.jewell_at_upm-kymmene.com)
Date: 08/31/04
- Next message: John W. Kennedy: "Re: Xah Lee's Unixism"
- Previous message: Jeff Epler: "Re: Splitting a list"
- Next in thread: Jeff Epler: "Re: Changing the decimal separator to a comma"
- Reply: Jeff Epler: "Re: Changing the decimal separator to a comma"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Aug 2004 07:12:59 -0700
I've tried using the locale module to set the locale correctly, but
all I get is "Error: unsupported locale setting".
I'm not actually sure what the proper setting should be; I think it's
"fi" for Finland, but this is what I get when I try (under py 2.2):
>>> locale.setlocale(locale.LC_ALL,"fi")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/python2.2.2/lib/locale.py", line 372, in setlocale
return _setlocale(category, locale)
locale.Error: locale setting not supported
Under 2.3 the call succeeds but makes no difference to the decimal
point (which should be a comma for Finland):
>>> locale.setlocale(locale.LC_ALL,"fi")
'Finnish_Finland.1252'
>>> 0.123
0.123
>>> "%10.2f" % 0.123
' 0.12'
The program I'm working on produces database records using a format
string, and I'm currently manually tracking all the dp's and replacing
them in a loop, just before writing the record to disk, but this is
inefficient and inelegant.
What I'd *like* to be able to do is specify that we want to use commas
for dp's or adjust the locale settings accordingly, then just write
the records directly from the format string...
regards,
-andyj
- Next message: John W. Kennedy: "Re: Xah Lee's Unixism"
- Previous message: Jeff Epler: "Re: Splitting a list"
- Next in thread: Jeff Epler: "Re: Changing the decimal separator to a comma"
- Reply: Jeff Epler: "Re: Changing the decimal separator to a comma"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|