Raymond Hettinger wrote: > Eric Smith pointed-out that these are already > handled by the "n" specifier in the locale module (albiet only > for integers). It's supported by float, but it's just not very useful. For Decimal it's unsupported. Maybe this isn't a distinction worth pointing out. > Proposal I (from Nick Coghlan) > ============================== ... > [[fill]align][sign][#][0][width][,][.precision][type] > Proposal II (to meet Antoine Pitrou's request) > ============================================== ... > [[fill]align][sign][#][0][width][T[tsep]][dsep precision][type] I was going to suggest that since the locale name for this is "grouping", we use "G". But since we're not doing a general-purpose grouping implementation, I think "T" better says "we're doing thousands, not general grouping. Perhaps this should go in a rationale section if we opt for "T". Now that I think about it, "G" is already a valid type, so it wouldn't work, anyway. > format(1234, "8T,d") --> ' 1,234' For proposal 2, this case is unfortunate. Because for integers, there is no decimal allowed in the mini-language (it's currently illegal to use "8.1d"), you'd only ever add the thousands, but you'd always need the "T". It would be nice to come up with a specification that would degrade for integers such that "8,d" would give ' 1,234'. Proposal 1 is much nicer in that regard, although I definitely like the fact that the actual characters used for DOT and COMMA can be specified with proposal 2. Maybe you'd never really use "T,", since the comma is redundant, and you'd say: format(1234, "8Td") --> ' 1,234' in normal use. But "d" is also the default, so it just becomes: format(1234, "8T") --> ' 1,234' I like approach 2 in general. I'll give some thought to other, similar schemes which would allow "8," or "8,d" to work. I think people will write "8," and expect " 1,234", not an error. Eric.
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