Re: [Python-ideas] Format mini-language for lakh and crore

2018-02-01 Thread Nick Coghlan
On 2 February 2018 at 08:23, Greg Ewing wrote: > Nick Coghlan wrote: >> >> - "," would be short for ",3," with decimal digits >> - "_" would be short for "_3_" with decimal digits >> - "_" would be short for "_4_" with binary/octal/hexadecimal digits > > > Is it necessary to restrict "," to decima

Re: [Python-ideas] Format mini-language for lakh and crore

2018-02-01 Thread Greg Ewing
Nick Coghlan wrote: - "," would be short for ",3," with decimal digits - "_" would be short for "_3_" with decimal digits - "_" would be short for "_4_" with binary/octal/hexadecimal digits Is it necessary to restrict "," to decimal? Why not make "," and "_" orthogonal? While "," with non-deci

Re: [Python-ideas] Format mini-language for lakh and crore

2018-02-01 Thread David Mertz
On Feb 1, 2018 12:17 AM, "Stephan Houben" wrote: What about something like: f"{x:₹d}" ₹ = Indian Rupees symbol I realize it is not ASCII but ₹ would be, for the target audience, both easy to type and be mnemonic ("format number like you would format an amount in rupees"). I like how iconic

Re: [Python-ideas] Format mini-language for lakh and crore

2018-02-01 Thread Eric V. Smith
On 2/1/2018 12:05 AM, David Mertz wrote: So overall I do like Nick's approach better than my initial suggestion or Eric's one that is similar to mine. Oops, I'd forgotten that you (David) had proposed a single character in your original email. I'm not trying to claim the idea! The important

Re: [Python-ideas] Format mini-language for lakh and crore

2018-02-01 Thread Stephan Houben
What about something like: f"{x:₹d}" ₹ = Indian Rupees symbol I realize it is not ASCII but ₹ would be, for the target audience, both easy to type (Ctrl-Alt-4 on Windows Indian English keyboard layout) and be mnemonic ("format number like you would format an amount in rupees"). Stephan 2018

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-31 Thread Nick Coghlan
On 1 February 2018 at 14:11, Nick Coghlan wrote: > On 1 February 2018 at 08:14, Eric V. Smith wrote: >> On 1/29/2018 2:13 AM, Nick Coghlan wrote: >>> Given the example, I think a more useful approach would be to allow an >>> optional digit grouping specifier after the comma separator, and allow >

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-31 Thread David Mertz
On Jan 31, 2018 8:12 PM, "Nick Coghlan" wrote: On 1 February 2018 at 08:14, Eric V. Smith wrote: >>> print(f"In European format x is {x:,.2f}, in Indian format it is {x:,2,3.2f}") > This just seems too complicated to me, and is overgeneralizing. How many of > these different formats would ever

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-31 Thread Nick Coghlan
On 1 February 2018 at 08:14, Eric V. Smith wrote: > On 1/29/2018 2:13 AM, Nick Coghlan wrote: >> Given the example, I think a more useful approach would be to allow an >> optional digit grouping specifier after the comma separator, and allow >> the separator to be repeated to indicate non-uniform

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-31 Thread Eric V. Smith
On 1/29/2018 2:13 AM, Nick Coghlan wrote: On 29 January 2018 at 11:48, Nathaniel Smith wrote: On Sun, Jan 28, 2018 at 5:31 PM, David Mertz wrote: I actually didn't know about `locale.format("%d", 10e9, grouping=True)`. But it's still much less general than having the option in the f-string/.f

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-29 Thread Nick Coghlan
On 30 January 2018 at 01:43, David Mertz wrote: > Nick suggests: > >>> print(f"In European format x is {x:,.2f}, in Indian format it > is {x:,2,3.2f}") > > This looks very good and general. I only know of the "European" and South > Asian conventions in widespread use, but we could give other

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-29 Thread David Mertz
Nick suggests: >>> print(f"In European format x is {x:,.2f}, in Indian format it is {x:,2,3.2f}") This looks very good and general. I only know of the "European" and South Asian conventions in widespread use, but we could give other grouping conventions using that little syntax and it definit

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-29 Thread Steve Dower
: Nathaniel Smith Sent: Monday, January 29, 2018 11:29 To: Eric V. Smith Cc: python-ideas Subject: Re: [Python-ideas] Format mini-language for lakh and crore On Sun, Jan 28, 2018 at 5:46 AM, Eric V. Smith wrote: > If I recall correctly, we discussed this at the time, and the problem with > loc

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Nick Coghlan
On 29 January 2018 at 11:48, Nathaniel Smith wrote: > On Sun, Jan 28, 2018 at 5:31 PM, David Mertz wrote: >> I actually didn't know about `locale.format("%d", 10e9, grouping=True)`. >> But it's still much less general than having the option in the >> f-string/.format() mini-language. This is rea

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Nathaniel Smith
On Sun, Jan 28, 2018 at 5:31 PM, David Mertz wrote: > I actually didn't know about `locale.format("%d", 10e9, grouping=True)`. > But it's still much less general than having the option in the > f-string/.format() mini-language. This is really about the formatted > string, not necessarily about th

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread David Mertz
I actually didn't know about `locale.format("%d", 10e9, grouping=True)`. But it's still much less general than having the option in the f-string/.format() mini-language. This is really about the formatted string, not necessarily about the locale. So, e.g. I'd like to be able to write: >>> print(

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Nathaniel Smith
On Sun, Jan 28, 2018 at 5:46 AM, Eric V. Smith wrote: > If I recall correctly, we discussed this at the time, and the problem with > locale is that it's not thread safe. I agree that if it were, it would be > nice to be able to use it, either with 'n', or in some other mode just for > grouping. >

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Steven D'Aprano
On Sun, Jan 28, 2018 at 09:51:05PM +1000, Nick Coghlan wrote: > Checking https://www.python.org/dev/peps/pep-0378/, we did suggest > using the locale module for cases where the engineering style > groups-of-three structure wasn't appropriate, with the parallel being > drawn to the fact that you al

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Eric V. Smith
On 1/28/2018 6:51 AM, Nick Coghlan wrote: On 28 January 2018 at 19:30, Stephan Houben wrote: Hi David, Perhaps the "n" locale-dependent number formatting specifier should accept a , to have locale-appropriate formatting of thousand separators? f"{x:,n}" would Do The Right Thing(TM) depending

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Nick Coghlan
On 28 January 2018 at 19:30, Stephan Houben wrote: > Hi David, > > Perhaps the "n" locale-dependent number formatting specifier > should accept a , to have locale-appropriate formatting of thousand > separators? > > f"{x:,n}" > > would Do The Right Thing(TM) depending on the locale. Checking http

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Alex Walters
easier to replace a function than change syntax. From: Python-ideas [mailto:python-ideas-bounces+tritium-list=sdamon@python.org] On Behalf Of David Mertz Sent: Sunday, January 28, 2018 1:25 AM To: python-ideas Subject: [Python-ideas] Format mini-language for lakh and crore In

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Stephan Houben
Hi David, Perhaps the "n" locale-dependent number formatting specifier should accept a , to have locale-appropriate formatting of thousand separators? f"{x:,n}" would Do The Right Thing(TM) depending on the locale. Today it is an error. Stephan 2018-01-28 7:25 GMT+01:00 David Mertz : > In So

[Python-ideas] Format mini-language for lakh and crore

2018-01-27 Thread David Mertz
In South Asia, a different style of digit delimiters for large numbers is used than in Europe, North America, Australia, etc. With some minor spelling differences, the term lakh is used for a hundred-thousand, and it is generally written as '1,00,000'. In turn, a crore is 100 lakh, and is written