[Python-Dev] Re: Be Honest about LC_NUMERIC [REPOST] (original) (raw)

Jeff Epler jepler at unpythonic.net
Tue Sep 2 11:44:03 EDT 2003


On Tue, Sep 02, 2003 at 11:29:55AM -0400, Tim Peters wrote:

OTOH, are there locales that insert thousandssep? I don't know. [...] There's no support there for the notion that "the formatted (etc)" functions can be affected by thousandssep, just that fiddling locale can affect decimal-point and the (passive) values returned by localeconv().

The Linux/glibc documentation, which cites SUSv2, seems to imply that no locale inserts the thousands separator in formatting operations, except when the ' flag character is included: For some numeric conversions a radix character ('decimal point') or thousands' grouping character is used. The actual character used depends on the LC_NUMERIC part of the locale. The POSIX locale uses '.' as radix character, and does not have a grouping character. Thus, printf("%'.2f", 1234567.89); results in '1234567.89' in the POSIX locale, in '1234567,89' in the nl_NL locale, and in '1.234.567,89' in the da_DK locale. [...] The five flag characters above are defined in the C standard. The SUSv2 specifies one further flag character.

   '      For decimal conversion (i, d, u, f, F, g, G) the output is to be
          grouped with thousands' grouping characters if the locale infor-
          mation indicates any.  Note that many  versions  of  gcc  cannot
          parse  this  option  and  will  issue a warning.  SUSv2 does not
          include %'F.

Jeff



More information about the Python-Dev mailing list