[Python-ideas] Rough draft: Proposed format specifier for a thousands separator (discussion moved from python-dev)

Lie Ryan lie.1296 at gmail.com
Wed Mar 18 03:47:22 CET 2009


Greg Ewing wrote:
> Mark Dickinson wrote:
> 
>>>>> format('%014f', 123.456, grouping=1)
>>
>> '0,000,123.456000'
>>
>> That also means that the relationship between the field width (14
>> in this case) and the string length (16) is somewhat obscured.
> 
> I'd consider that part a bug that we shouldn't imitate.
> The field width should always be what you say it is,
> unless the value is too big to fit.
> 

Should there be an option for using hard-width? If hard-width flag is 
on, then if the value is too big to fit, then the number will get 
trimmed instead of changing the width (and perhaps there would be 
prepend character).

So:

width: 4, number: 123456, ppchar

"<456"

So not to break table alignment...




More information about the Python-ideas mailing list