Rough draft: Proposed format specifier for a thousands separator
MRAB
google at mrabarnett.plus.com
Sun Mar 15 15:00:43 EDT 2009
Rhodri James wrote:
[snip]
> Frankly, I'd much rather fix the locale system and extend
> the format syntax to override the default locale. Perhaps
> something like
>
> financial = Locale(group_sep=",", grouping=[3])
> print("my number is {0:10n:financial}".format(1234567))
>
> It's hard to think of a way of extending "%" format strings
> to cope with this that won't look utterly horrid, though!
>
The problem with your example is that it magically looks for the locale
name "financial" in the current namespace. Perhaps the name should be
registered somewhere like this:
locale.predefined["financial"] = Locale(group_sep=",", grouping=[3])
print("my number is {0:10n:financial}".format(1234567))
More information about the Python-list
mailing list