[issue43624] Add underscore as a decimal separator for string formatting

2021-05-04 Thread Terry Davis
Terry Davis added the comment: If no one else has any comments, I'll assume there is consensus and start working on this. I have not contributed to CPython before, nor have I worked on production C code, so it may be a while before I get anywhere. -- versions: +Python 3.11 -Python 3.

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-29 Thread Terry Davis
Terry Davis added the comment: Current behavior: >>> format(1234.1234, '_f') '1_234.123400' >>> format(1234.1234, ',f') '1,234.123400' New behavior: >>> format(1234.1234, ',._f') '1,234.123_400' >>> format(1234.1234, '_._f') '1_234.123_400' >>> format(1234.1234, '._f') '1234.123_400' >>> form

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-29 Thread STINNER Victor
STINNER Victor added the comment: I'm now confused. Would you mind to give examples of all proposed formats and the expected output? -- ___ Python tracker ___ ___

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-29 Thread Terry Davis
Terry Davis added the comment: Victor, > '_.f' would be the same as '_f'? No, the example in my original post is wrong, '_.f' isn't allowed now. The proposal should use '_f' to describe the current behavior. > Should "._f" be allowed to only add underscores in the fractional part? (for > cons

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-29 Thread STINNER Victor
STINNER Victor added the comment: Raymond: > I prefer Terry's original proposal which is backwards compatible (...) Well ok, that's what I expected. Backward compatibility usually wins all other arguments in Python :-) But I had to ask the question :-) -- ___

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-29 Thread STINNER Victor
STINNER Victor added the comment: '_.f' would be the same as '_f'? Should "._f" be allowed to only add underscores in the fractional part? (for consistency?) -- ___ Python tracker _

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-29 Thread Eric V. Smith
Eric V. Smith added the comment: I agree with Raymond. We can't make a change that would modify existing program output. Which is unfortunate, but such is life. And I'd prefer to see groupings of 5 on the right, but I realize I might be in the minority. -- _

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: I prefer Terry's original proposal which is backwards compatible and gives the user control over whether separator is to be applied to the fractional component. >>> format(12_34_56.12_34_56, '_._f') # Whole and fractional '123_456.123_456' >>> format

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-29 Thread STINNER Victor
STINNER Victor added the comment: > On the other hand, I suppose it would be possible to have a feature flag that > can be used to disable decimal underscores in 3.10 to prevent test failures. > Just spitballing... I wrote PEP 606 -- Python Compatibility Version https://www.python.org/dev/p

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-26 Thread Terry Davis
Terry Davis added the comment: Good point Victor, though I wonder how likely it is that a person using 3.10 would only use this particular new feature, and have an otherwise backwards-compatible codebase. This isn't something that I asked about out of necessity, and there hasn't been any ot

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-26 Thread STINNER Victor
STINNER Victor added the comment: How backward incompatible and annoying would it be to modify the behavior of the existing "_f" format? Do you see use cases which only want to group digits in the integer part but not the fractional part? According to https://discuss.python.org/t/add-under

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-26 Thread STINNER Victor
STINNER Victor added the comment: > If we do anything for float, we should do the same for decimal.Decimal. and complex ;-) -- ___ Python tracker ___

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Eric V. Smith
Eric V. Smith added the comment: If we do anything for float, we should do the same for decimal.Decimal. -- ___ Python tracker ___

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Eric V. Smith
Change by Eric V. Smith : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Dominic Davis-Foster
Dominic Davis-Foster added the comment: ISO 8-1:2009 recommends groups of three digits either side of the decimal sign. -- nosy: +domdfcoding ___ Python tracker ___ _

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread STINNER Victor
Change by STINNER Victor : -- nosy: +vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: Some brief research === """ in numbers four or more digits long, use commas to set off groups of three digits, counting leftward from the decimal point, in the standard American style. For long decimal numbers, do not use any digit-group se

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: IIRC there is ISO recommending that after the decimal point, digits be arranged in groups of five. I think is also how printed reference tables are typically formatted. -- nosy: +mark.dickinson, rhettinger, serhiy.storchaka _

[issue43624] Add underscore as a decimal separator for string formatting

2021-03-25 Thread Terry Davis
New submission from Terry Davis : Proposal: Enable this >>> format(12_34_56.12_34_56, '_._f') '123_456.123_456' Where now only this is possible >>> format(12_34_56.12_34_56, '_.f') '123_456.123456' Based on the discussion in the Ideas forum, three core devs support this addition. https://dis