Changing the decimal separator to a comma

From: andyj (andrew.jewell_at_upm-kymmene.com)
Date: 08/31/04


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



Relevant Pages

  • Re: How to over-ride US Date Format?
    ... >>I've checked my Regional Settings and they're definitely in UK format. ... You can get your international locale setting to be ... > used by letting Access convert a date in a string either ...
    (microsoft.public.access.queries)
  • Re: Tk::Entry and unicode/UTF8 file name problems
    ... It recodes it to UTF8 though my locale setting is ISO-8859-1! ... The bug is in Tk and my workaround (for UNIX) is: ... return $string; ...
    (comp.lang.perl.tk)
  • Re: TERM setting? strange chars in man page
    ... Henry Townsend wrote: ... like it's always the same string. ... I see no pattern for where they appear ... Perhaps it's related to your locale setting (or from a file generated under ...
    (comp.unix.programmer)
  • Re: CDBL Function truncates decimals
    ... Is there a way to format a number into US ... Public Function ConvertNumberforSQL (ByVal sValue As String, ... Since the Spanish formatting has a comma, the SQL statement seems to have ...
    (microsoft.public.vb.general.discussion)
  • Re: Handling floating point with decimal comma separator to filter a form
    ... Lets say the user wants to filter values between 1,1 and 1,9 (note that the user wiil enter the number with a comma sparator, not with a dot - and the Standard format will be of no help here). ... Dim strWhere As String ...
    (microsoft.public.access.formscoding)