A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-March/087109.html below:

[Python-Dev] Formatting mini-language suggestion

[Python-Dev] Formatting mini-language suggestionJames Y Knight foom at fuhm.net
Thu Mar 12 05:36:35 CET 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 is
>> not universal.   For a thousands separator, a comma is a decent  
>> choice
>> that 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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4