Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-22 Thread rzed
Raymond Hettinger pyt...@rcn.com wrote in news:e35271b9-7623-4845-bcb9-d8c33971f...@w24g2000prd.googlegroups.c om: If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin in

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-16 Thread Rhodri James
On Mon, 16 Mar 2009 02:36:43 -, MRAB goo...@mrabarnett.plus.com wrote: The field name can be an integer or an identifier, so the locale could be too, provided that you know where to look it up! financial = Locale(group_sep=,, grouping=[3]) print(my number is

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-16 Thread MRAB
Rhodri James wrote: On Mon, 16 Mar 2009 02:36:43 -, MRAB goo...@mrabarnett.plus.com wrote: The field name can be an integer or an identifier, so the locale could be too, provided that you know where to look it up! financial = Locale(group_sep=,, grouping=[3]) print(my number is

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-16 Thread Rhodri James
On Mon, 16 Mar 2009 23:04:58 -, MRAB goo...@mrabarnett.plus.com wrote: It should probably(?) be: financial = Locale(group_sep=,, grouping=[3]) print(my number is {0:10n:fin}.format(1234567, fin=financial)) The format 10n says whether to use separators or a decimal point; the

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-16 Thread MRAB
Rhodri James wrote: On Mon, 16 Mar 2009 23:04:58 -, MRAB goo...@mrabarnett.plus.com wrote: It should probably(?) be: financial = Locale(group_sep=,, grouping=[3]) print(my number is {0:10n:fin}.format(1234567, fin=financial)) The format 10n says whether to use separators or a

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-16 Thread Rhodri James
On Tue, 17 Mar 2009 01:47:32 -, MRAB goo...@mrabarnett.plus.com wrote: I'm not against putting a comma in the format to indicate that grouping should be used just as a dot indicates that a decimal point should be used. The locale would say what characters would be used for them. I would

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-16 Thread MRAB
Rhodri James wrote: On Tue, 17 Mar 2009 01:47:32 -, MRAB goo...@mrabarnett.plus.com wrote: I'm not against putting a comma in the format to indicate that grouping should be used just as a dot indicates that a decimal point should be used. The locale would say what characters would be used

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-16 Thread Rhodri James
On Tue, 17 Mar 2009 02:41:23 -, MRAB goo...@mrabarnett.plus.com wrote: Rhodri James wrote: On Tue, 17 Mar 2009 01:47:32 -, MRAB goo...@mrabarnett.plus.com wrote: I'm not against putting a comma in the format to indicate that grouping should be used just as a dot indicates that a

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread Hendrik van Rooyen
Tim Rowe digil.com wrote: 8 - . If Finance users and non-professional programmers find the locale approach to be frustrating, arcane and non-obvious then by all means propose a way of making it simpler and clearer,

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread Hendrik van Rooyen
Paul Rubin http://phr...@nospam.invalid wrote: Paul Rubin http://phr...@nospam.invalid writes: '%.3K' % 1234567 = 1.235K # K = 1000 '%.:3Ki' % 1234567 = 1.206K # K = 1024 I meant 1.235M and 1.177M, of course. I went tilt like a slot machine long before I noticed... :-) -

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread JanC
Raymond Hettinger wrote: No doubt that you're skeptical of anything you didn't already know ;-) 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. Besides, it seems

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread Rhodri James
On Sat, 14 Mar 2009 08:20:21 -, Hendrik van Rooyen m...@microcorp.co.za wrote: Tim Rowe digil.com wrote: 8 - . If Finance users and non-professional programmers find the locale approach to be frustrating,

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread MRAB
Rhodri James wrote: [snip] Frankly, I'd much rather fix the locale system and extend the format syntax to override the default locale. Perhaps something like financial = Locale(group_sep=,, grouping=[3]) print(my number is {0:10n:financial}.format(1234567)) It's hard to think of a way of

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread Tim Rowe
2009/3/14 Hendrik van Rooyen m...@microcorp.co.za: No account seems to be taken of the fact that the locale approach is a global one that forces uniformity on everything done on a PC or by a user. Not so. Under .NET, for instance, the global settings will give you a default CultureInfo class,

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread Rhodri James
On Sun, 15 Mar 2009 19:00:43 -, MRAB goo...@mrabarnett.plus.com wrote: Rhodri James wrote: [snip] Frankly, I'd much rather fix the locale system and extend the format syntax to override the default locale. Perhaps something like financial = Locale(group_sep=,, grouping=[3])

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread MRAB
Rhodri James wrote: On Sun, 15 Mar 2009 19:00:43 -, MRAB goo...@mrabarnett.plus.com wrote: Rhodri James wrote: [snip] Frankly, I'd much rather fix the locale system and extend the format syntax to override the default locale. Perhaps something like financial = Locale(group_sep=,,

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-14 Thread Raymond Hettinger
[Lie Ryan] My proposition is: make the format specifier a simpler API to locale aware You do know that we already have one, right? That's what the existing n specifier does. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-14 Thread Hendrik van Rooyen
John Nagle na...@animats.com wrote: Yes. In COBOL, one writes PICTURE $999,999,999.99 which is is way ahead of most of the later approaches. That was fixed width. For zero suppression: PIC ,$$$,$99.99 This will format 1000 as $1,000.00 For fixed width zero suppression: PIC

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Hendrik van Rooyen wrote: Ulrich Eckhardt eck...aser.com wrote: IOW, why not explicitly say what you want using keyword arguments with defaults instead of inventing an IMHO cryptic, read-only mini-language? Seriously, the problem I see with this proposal is that its aim to be as short as

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Raymond Hettinger
[Lie Ryan] A hyphotetical code using conv function and the microlanguage could look like this:   num = 213210.3242   fmt = create_format(sep='-', decsep='@')   print fmt 50|\/|3_v3ry_R34D4|3L3_C0D3   '{0!{1}}'.format(num, fmt) '213-...@3242' LOL, it's like APL all over again ;-) FWIW,

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread andrew cooke
Raymond Hettinger wrote: [Lie Ryan] A hyphotetical code using conv function and the microlanguage could look like this:   num = 213210.3242   fmt = create_format(sep='-', decsep='@')   print fmt 50|\/|3_v3ry_R34D4|3L3_C0D3   '{0!{1}}'.format(num, fmt) '213-...@3242' LOL, it's like APL

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Paul Rubin
Raymond Hettinger pyt...@rcn.com writes: The proposal is roughly: If you want commas in the output, put a comma in the format string. It's not rocket science. What if you want to change the separator? Europeans usually use periods instead of commas: one thousand = 1.000. --

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Raymond Hettinger
[andrew cooke] would it break anything to also allow format(1234567, 'd')       # what we have now  '1234567' format(1234567, '.d')      # proposed new option  '1.234.567' format(1234.5, ',2f')      # proposed new option  '1234,50' format(1234.5, '.,2f')     # proposed new option

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Raymond Hettinger
[Paul Rubin] What if you want to change the separator?  Europeans usually use periods instead of commas: one thousand = 1.000. That is supported also. -- http://mail.python.org/mailman/listinfo/python-list

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Tim Rowe
2009/3/12 Raymond Hettinger pyt...@rcn.com: If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin in Py2.6 and Py3.0:  http://docs.python.org/library/string.html#formatspec

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Wolfgang Rohdewald
On Freitag, 13. März 2009, Raymond Hettinger wrote: [Paul Rubin] What if you want to change the separator? Europeans usually use periods instead of commas: one thousand = 1.000. That is supported also. do you support just a fixed set of separators or anything? how about this:

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread pruebauno
On Mar 13, 7:06 am, Tim Rowe digi...@gmail.com wrote: 2009/3/12 Raymond Hettinger pyt...@rcn.com: If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin in Py2.6 and

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Tim Rowe
2009/3/13 prueba...@latinmail.com: I think this proposal is more for debugging big numbers and meant mostly for programmers' eyes. We are already using the dot instead of comma decimal separator in our programming languages that one more Americanism won't kill us. If it were for the

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: [andrew cooke] would it break anything to also allow format(1234567, 'd') # what we have now '1234567' format(1234567, '.d') # proposed new option '1.234.567' format(1234.5, ',2f') # proposed new option '1234,50' format(1234.5, '.,2f') #

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Raymond Hettinger
 The separators can be any one of COMMA, SPACE, DOT, UNDERSCORE, or NON-BREAKING-SPACE. What if I want other separators? format(n, ',d').replace(,, yoursep) How about this idea: make the format has long format, which is a bit more verbose, flexible, and unambiguous, and the current

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread John Nagle
Lie Ryan wrote: Hendrik van Rooyen wrote: Ulrich Eckhardt eck...aser.com wrote: Look back in history, and see how COBOL did it with the PICTURE - dead easy and easily understandable. Compared to that, even the C printf stuff and python's % are incomprehensible. - Hendrik Yes. In

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Raymond Hettinger
Todays updates to: http://www.python.org/dev/peps/pep-0378/ * Detail issues with the locale module. * Summarize commentary to date. -- Opposition to formatting strings in general (preferring a convenience function or PICTURE clause) -- Opposition to any non-locale aware approach *

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread MRAB
Raymond Hettinger wrote: Todays updates to: http://www.python.org/dev/peps/pep-0378/ * Detail issues with the locale module. * Summarize commentary to date. -- Opposition to formatting strings in general (preferring a convenience function or PICTURE clause) -- Opposition to any

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Paul Rubin
Tim Rowe digi...@gmail.com writes: And if it's mostly for programmers' eyes, why does the motivation state that Adding thousands separators is one of the simplest ways to improve the professional appearance and readability of output exposed to end users? It occurs to me, at least for

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Paul Rubin
Paul Rubin http://phr...@nospam.invalid writes: '%.3K' % 1234567 = 1.235K # K = 1000 '%.:3Ki' % 1234567 = 1.206K # K = 1024 I meant 1.235M and 1.177M, of course. -- http://mail.python.org/mailman/listinfo/python-list

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: Motivation: Provide a simple, non-locale aware way to format a number with a thousands separator. Adding thousands separators is one of the simplest ways to improve the professional appearance and readability of output exposed to end users.

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Raymond Hettinger
[Lie Ryan]       In the finance world, output with commas is the norm. I can't cite any source, but I am skeptical with that. No doubt that you're skeptical of anything you didn't already know ;-) I'm a CPA, was a 15 year division controller for a Fortune 500 company, and an auditor for an

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin in Py2.6 and Py3.0: http://docs.python.org/library/string.html#formatspec

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: [Lie Ryan] In the finance world, output with commas is the norm. I can't cite any source, but I am skeptical with that. No doubt that you're skeptical of anything you didn't already know ;-) I'm a CPA, was a 15 year division controller for a Fortune 500

Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Raymond Hettinger
If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin in Py2.6 and Py3.0: http://docs.python.org/library/string.html#formatspec

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Raymond Hettinger
If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin: http://docs.python.org/library/string.html#formatspec Here's a re-post (hopefully without the line wrapping problems in

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Ulrich Eckhardt
Raymond Hettinger wrote: The idea is to make numbering formatting a little easier with the new format() builtin: http://docs.python.org/library/string.html#formatspec [...] Scanning the web, I've found that thousands separators are usually one of COMMA, PERIOD, SPACE, or UNDERSCORE. The

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Raymond Hettinger
[Ulrich Eckhardt] IOW, why not explicitly say what you want using keyword arguments with defaults instead of inventing an IMHO cryptic, read-only mini-language? That makes sense to me but I don't think that's the way the format() builtin was implemented (see PEP 3101 which was implemented Py2.6

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread MRAB
Raymond Hettinger wrote: [snip] Proposal I (from Nick Coghlan): --- A comma will be added to the format() specifier mini-language: [[fill]align][sign][#][0][minimumwidth][,][.precision][type] The ',' option indicates that commas should be included in the output as

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Hendrik van Rooyen
Ulrich Eckhardt eck...aser.com wrote: IOW, why not explicitly say what you want using keyword arguments with defaults instead of inventing an IMHO cryptic, read-only mini-language? Seriously, the problem I see with this proposal is that its aim to be as short as possible actually makes the

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread John Machin
On Mar 12, 9:56 pm, Raymond Hettinger pyt...@rcn.com wrote: [Ulrich Eckhardt] IOW, why not explicitly say what you want using keyword arguments with defaults instead of inventing an IMHO cryptic, read-only mini-language? That makes sense to me but I don't think that's the way the format()

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread pruebauno
On Mar 12, 3:30 am, Raymond Hettinger pyt...@rcn.com wrote: If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin in Py2.6 and Py3.0:  

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Raymond Hettinger
On Mar 12, 7:51 am, prueba...@latinmail.com wrote: On Mar 12, 3:30 am, Raymond Hettinger pyt...@rcn.com wrote: If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Paul Rubin
Raymond Hettinger pyt...@rcn.com writes: FWIW, posted a cleaned-up version of the proposal at http://www.python.org/dev/peps/pep-0378/ It would be nice if the PEP included a comparison between the proposed scheme and how it is done in other programs and languages. For example, I think Common

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Raymond Hettinger
[Paul Rubin] It would be nice if the PEP included a comparison between the proposed scheme and how it is done in other programs and languages. Good idea. I'm hoping that people will post those here. In my quick research, it looks like many languages offer nothing more than the usual C style %

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Raymond Hettinger
[Paul Rubin] I think Common Lisp has a feature for formatting thousands. I found the Common Lisp spec for this and added it to the PEP. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Paul Rubin
Raymond Hettinger pyt...@rcn.com writes: In my quick research, it looks like many languages offer nothing more than the usual C style % formatting and defer the rest for a local aware module. Hendrik van Rooyen's mention of Cobol's picture (aka PIC) specifications might be added to the list.

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Paul Rubin
Raymond Hettinger pyt...@rcn.com writes: I found the Common Lisp spec for this and added it to the PEP. Ah, cool, I simultaneously looked for it and posted about it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Scott David Daniels
Raymond Hettinger wrote: ... a generally interesting PEP... Missing from this PEP: output below the decimal point. show results for something like: format(12345.54321, 15,.5f) -- ' 12,345.543,21' Explain the interaction on sizes and lengths (which numbers are digits, which are length [I