Re: [Python-ideas] Rough draft: Proposed format specifier for a thousands separator (discussion moved from python-dev)
[spir]
Probably you know that already, but it doesn't hurt anyway. In french and most rroman languages comma is the standard decimal sep; and either space or dot is used, when necessary, to sep thousands. (It's veeery difficult for me to read even short numbers with commas used as thousand separator.)
en: 1,234,567.89 fr: 1.234.567,89 or: 1 234 567,89
Thanks for the informative comment. It looks like your needs are best met by Proposal II where those would be written as: en_num = format(x, "12T, 2f") fr_num = format(x, "12T.,2f") or_num =format(x, "12T ,2f") Raymond
Raymond Hettinger writes:
Thanks for the informative comment. It looks like your needs are best met by Proposal II where those would be written as:
en_num = format(x, "12T, 2f") fr_num = format(x, "12T.,2f") or_num = format(x, "12T ,2f")
That is way unreadable to me, especially the difference between en_num and or_num. Also, I wonder if en_num = format(x, "12T,.2f") isn't more explicit.
Raymond Hettinger <python@...> writes:
or_num =format(x, "12T ,2f")
In many cases, the space would have to be a non-breaking space, but it's probably too complicated for your PEP. Regards Antoine.
On Thu, 12 Mar 2009 00:49:24 -0700, Raymond Hettinger wrote:
[spir]
Probably you know that already, but it doesn't hurt anyway. In french and most rroman languages comma is the standard decimal sep; and either space or dot is used, when necessary, to sep thousands. (It's veeery difficult for me to read even short numbers with commas used as thousand separator.)
en: 1,234,567.89 fr: 1.234.567,89 or: 1 234 567,89
I'll notice that the international standard is to use just space: http://www.bipm.org/jsp/en/ViewCGPMResolution.jsp?CGPM=22&RES=10 reaffirms that "Numbers may be divided in groups of three in order to facilitate reading; neither dots nor commas are ever inserted in the spaces between groups", as stated in Resolution 7 of the 9th CGPM, 1948. In Italian, we use a character which is not available in keyboard, nor I find it in an Unicode map, so let's ignore it :) On computers, we usually simply put a period between thousands. -- Giovanni Bajo Develer S.r.l. http://www.develer.com
On Sun, Mar 15, 2009 at 3:20 PM, Giovanni Bajo <rasky@develer.com> wrote:
On Thu, 12 Mar 2009 00:49:24 -0700, Raymond Hettinger wrote:
[spir]
Probably you know that already, but it doesn't hurt anyway. In french and most rroman languages comma is the standard decimal sep; and either space or dot is used, when necessary, to sep thousands. (It's veeery difficult for me to read even short numbers with commas used as thousand separator.)
en: 1,234,567.89 fr: 1.234.567,89 or: 1 234 567,89
I'll notice that the international standard is to use just space:
http://www.bipm.org/jsp/en/ViewCGPMResolution.jsp?CGPM=22&RES=10
Of course, that's primarily a /scientific/ standard; others have explained that commas are apparently the international /financial/ standard. "Aren't standards great? There's so many to choose from!" This thread continues to get more complicated by the day... (Localization doth be *hard*) Cheers, Chris -- I have a blog: http://blog.rebertia.com
[Chris Rebert]
This thread continues to get more complicated by the day... (Localization doth be *hard*)
Good thing the PEP is *not* about localization :-) It does not attempt to cater to every possible way to write numbers. Instead, it offers a handful of choices for thousands groupings. At least one of those choices (perhaps spaces or underscores) should be readable and useful in many (though not all) contexts. Raymond
Raymond Hettinger wrote:
[Chris Rebert]
This thread continues to get more complicated by the day... (Localization doth be *hard*)
Good thing the PEP is *not* about localization :-) It does not attempt to cater to every possible way to write numbers. Instead, it offers a handful of choices for thousands groupings. At least one of those choices (perhaps spaces or underscores) should be readable and useful in many (though not all) contexts.
Emphatically agreed that this PEP shouldn't be targeted at end-user output for a commercial product. There are plenty of good solutions for that already in the l10n/i18n space. What is currently missing (and what the PEP will provide) is the ability to easily output more readable comparatively large integers for debugging output or quick and dirty "internal" scripts that are not intended for wide distribution. Having had my eyes glaze over attempting to decipher overly long integers in debugging output, I look forward to the day when I no longer have to write my own formatting functions to deal with that (even if the time when I can use 2.7 or 3.1 day to day is still somewhere in the dim distant future...) On a completely different topic, I noticed that the PEP doesn't currently state what the thousands separator means for bases other than 10 (i.e. octal, hex, binary). Is it ignored? Always delineates groups of 3 digits as for decimal numbers? Delineates an "appropriate" group size (e.g. 3 for octal, 4 for hex and binary)? Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------
Le Sun, 15 Mar 2009 15:34:54 -0700, Chris Rebert <pyideas@rebertia.com> s'exprima ainsi:
commas are apparently the international /financial/ standard
Certainly not! I am very surprised to read that. Do you mean the standard in english-speaking countries? Or in countries which currency is $ or £? see http://en.wikipedia.org/wiki/Decimal_point#Examples_of_use Denis ------ la vita e estrany
On Mon, Mar 16, 2009 at 7:10 AM, spir <denis.spir@free.fr> wrote:
Le Sun, 15 Mar 2009 15:34:54 -0700, Chris Rebert <pyideas@rebertia.com> s'exprima ainsi:
commas are apparently the international /financial/ standard
Certainly not! I am very surprised to read that. Do you mean the standard in english-speaking countries? Or in countries which currency is $ or £?
see http://en.wikipedia.org/wiki/Decimal_point#Examples_of_use
Yes, I know it varies from nation to nation, but apparently less so when specifically working internationally (like you, I was surprised there was a standard at all); see earlier response by Raymond Hettinger in the parallel c.l.p thread. Relevant quote: """ I'm a CPA, was a 15 year division controller for a Fortune 500 company, and an auditor for an international accounting firm. Believe me when I say it is the norm in finance. """ "It" referring to period-as-decimal-point and comma-as-thousands-separator notation. Cheers, Chris -- I have a blog: http://blog.rebertia.com
"It" referring to period-as-decimal-point and comma-as-thousands-separator notation.
Guys, I just meant that grouping of thousands is common in finance. The actual grouping separator varies. Raymond
On Mon, Mar 16, 2009 at 9:42 AM, Raymond Hettinger <python@rcn.com> wrote:
"It" referring to period-as-decimal-point and comma-as-thousands-separator notation.
Guys, I just meant that grouping of thousands is common in finance. The actual grouping separator varies.
Ah, evidently I misinterpreted. Apologies. Cheers, Chris
Chris Rebert <pyideas@rebertia.com> wrote:
On Mon, Mar 16, 2009 at 7:10 AM, spir <denis.spir@free.fr> wrote:
Le Sun, 15 Mar 2009 15:34:54 -0700, Chris Rebert <pyideas@rebertia.com> s'exprima ainsi:
commas are apparently the international /financial/ standard
Certainly not! I am very surprised to read that. Do you mean the standard in english-speaking countries? Or in countries which currency is $ or £?
see http://en.wikipedia.org/wiki/Decimal_point#Examples_of_use
Yes, I know it varies from nation to nation, but apparently less so when specifically working internationally (like you, I was surprised there was a standard at all); see earlier response by Raymond Hettinger in the parallel c.l.p thread. Relevant quote:
""" I'm a CPA, was a 15 year division controller for a Fortune 500 company, and an auditor for an international accounting firm. Believe me when I say it is the norm in finance. """
"It" referring to period-as-decimal-point and comma-as-thousands-separator notation.
Regardless of any standards, I find it interesting that I just now ran into exactly the use case that prompted Raymond to propose this addition. I need to format a one-off report for a client, and it would be _most_ helpful if I could easily tell Python to format the numbers, which are reporting bytes transmitted, with comma thousands separators for clarity. I guess that means I'm +1 for some form of this making it through. -- R. David Murray http://www.bitdance.com
participants (8)
-
Antoine Pitrou
-
Chris Rebert
-
Giovanni Bajo
-
Nick Coghlan
-
R. David Murray
-
Raymond Hettinger
-
spir
-
Stephen J. Turnbull