python-dev
[Prev] Thread [Next] | [Prev] Date [Next]
Re: [Python-Dev] Formatting mini-language suggestion James Y Knight Wed Mar 11 22:00:35 2009
On Mar 11, 2009, at 11:40 PM, Nick Coghlan wrote:
Raymond Hettinger wrote:It is not the goal to replace locale or to accomodate every possible convention. The goal is to make a common task easier for many users. The current, default use of the period as a decimal point has not proven to be problem eventhough that convention isnot universal. For a thousands separator, a comma is a decent choicethat makes it easy follow-on with s.replace(',', '_') or somesuch.In that case, I would simplify my suggestion to: [[fill]align][sign][#][0][minimumwidth][,][.precision][type] Addition to mini language documentation: The ',' option indicates that commas should be included in the output as a thousands separator. As with locales which do not use a period as the decimal point, locales which use a different convention for digit separation will need to use the locale module to obtain appropriate formatting.
This proposal has the advantage that you're not overly specifying the behavior in the format string itself.
That is: the "," option is really just indicating "please insert separators". With the current locale-ignorant implementation, that'd just mean "a comma every 3 digits". But it leaves the door open for a locale-sensitive variant of the format to be added in the future without conflicting with the instructions in the format string. (as the ability to specify an arbitrary character, or the ability to specify a comma instead of a period for the decimal point would).
I'm not against Raymond's proposal, just against doing a *bad* job of making it work in multiple locales. Locale conventions can be complex, and are going to be best represented outside the format string.
(BTW: single quote is used by printf for the grouping flag rather than comma)
James _______________________________________________ Python-Dev mailing list [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/alexiscircle%40gmail.com
- [Python-Dev] Formatting mini-language suggestion Raymond Hettinger
- Re: [Python-Dev] Formatting mini-language suggestion Antoine Pitrou
- Re: [Python-Dev] Formatting mini-language suggestion Guido van Rossum
- Re: [Python-Dev] Formatting mini-language suggestion Raymond Hettinger
- Message not available
- Re: [Python-Dev] Formatting mini-language suggestion Guido van Rossum
- Re: [Python-Dev] Formatting mini-language suggestion Nick Coghlan
- Re: [Python-Dev] Formatting mini-language suggestion James Y Knight
- Re: [Python-Dev] Formatting mini-language suggestion Raymond Hettinger
- Re: [Python-Dev] Formatting mini-language suggestion Nick Coghlan
- Re: [Python-Dev] Formatting mini-language suggestion James Y Knight <=
- Re: [Python-Dev] Formatting mini-language suggestion Lie Ryan
- Re: [Python-Dev] Formatting mini-language suggestion Raymond Hettinger
- Re: [Python-Dev] Formatting mini-language suggestion Jeroen Ruigrok van der Werven
- Re: [Python-Dev] Formatting mini-language suggestion Ben Finney
- Re: [Python-Dev] Formatting mini-language suggestion Greg Ewing
Re: [Python-Dev] Formatting mini-language suggestion Greg Ewing
- Re: [Python-Dev] Formatting mini-language suggestion Stephen J. Turnbull
- Re: [Python-Dev] Formatting mini-language suggestion Greg Ewing
- Re: [Python-Dev] Formatting mini-language suggestion Stephen J. Turnbull