On Mon, 16 Mar 2009 23:04:58 -0000, MRAB <goo...@mrabarnett.plus.com> wrote:

It should probably(?) be:

     financial = Locale(group_sep=",", grouping=[3])
     print("my number is {0:10n:fin}".format(1234567, fin=financial))

The format "10n" says whether to use separators or a decimal point; the
locale "fin" says what the separator and the decimal point look like.

That works, and isn't an abomination on the face of the existing syntax. Excellent.

I'm rather presuming that the "n" presentation type does grouping. I've only got Python 2.5 here, so I can't check it out (no str.format() method and "%n" isn't supported by "%" formatting). If it does, an "m" type to do the same thing only with the LC_MONETARY group settings instead of the LC_NUMERIC ones would be a good idea.

This would be my preferred solution to Raymond's original comma-in-the-format-string proposal, by the way: add an "m" presentation type as above, and tell people to override the LC_MONETARY group settings in the global locale. It's clear that it's a bodge, and weaning users onto local locales (!) wouldn't be so hard later on.

Anyway, time I stopped hypothesising about locales and started looking at the actual code-base, methinks.

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to