Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-06 Thread Nick Coghlan
Vinay Sajip wrote: > Both of these approaches will also work for {}-formatting. The present thread > really started out with a view to suggesting that the stdlib start adopting > {}-format as "native", rather than %-format. > > Would it be helpful if I added a section to the Python docs about how

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-05 Thread Nick Coghlan
Barry Warsaw wrote: > I also don't think this is a case of anti-TOOWTDI. For most situations > {}-strings are great (IMO), but in the specific translation domain, I > suspect $-strings are still better. I agree that keeping string.Template around is valid due to its focus on being very simple to

Re: [Python-Dev] summary of transitioning from % to { } formatting

2009-10-05 Thread Vinay Sajip
Nick Coghlan gmail.com> writes: > Oh, I see what you meant now - you were pointing out that lazy > formatting APIs (such as logging) already don't work properly for > alternative formatting mechanisms (such as string.Template). > Logging doesn't work automatically with string.Template as it pre

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-05 Thread Barry Warsaw
On Oct 5, 2009, at 4:41 PM, Nick Coghlan wrote: Oh, I see what you meant now - you were pointing out that lazy formatting APIs (such as logging) already don't work properly for alternative formatting mechanisms (such as string.Template). Yep. (Although printing to a String IO doesn't seem ne

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-05 Thread Nick Coghlan
Barry Warsaw wrote: > On Oct 4, 2009, at 4:11 AM, Nick Coghlan wrote: > >> Barry Warsaw wrote: >>> I also don't think this is a case of anti-TOOWTDI. For most situations >>> {}-strings are great (IMO), but in the specific translation domain, I >>> suspect $-strings are still better. >> >> I agree

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-05 Thread Barry Warsaw
On Oct 4, 2009, at 4:11 AM, Nick Coghlan wrote: Barry Warsaw wrote: I also don't think this is a case of anti-TOOWTDI. For most situations {}-strings are great (IMO), but in the specific translation domain, I suspect $-strings are still better. I agree that keeping string.Template around i

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-04 Thread Nick Coghlan
Brett Cannon wrote: > No one is saying we should deprecate % any time soon on strings > themselves or anywhere. This discussion is purely in regards to > argparse and logging to transition *their* APIs over to {} formatting > which would most likely involve some deprecation for *using* % > formatti

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-04 Thread Nick Coghlan
Antoine Pitrou wrote: > If we can't find a way to make things almost transparent, we should IMO > abandon > the whole idea of a transition. Yep - this is the reason some attempts at actual format translation implementations started up as a result of the previous discussion. Without that, I suspec

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread MRAB
Terry Reedy wrote: Steven Bethard wrote: I thought it might be useful for those who don't have time to read a million posts to have a summary of what's happened in the formatting discussion. definitely The basic problem is that many APIs in the standard library and elsewhere support only %-

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread Terry Reedy
Steven Bethard wrote: I thought it might be useful for those who don't have time to read a million posts to have a summary of what's happened in the formatting discussion. definitely The basic problem is that many APIs in the standard library and elsewhere support only %-formatting and not {

Re: [Python-Dev] summary of transitioning from % to { } formatting

2009-10-03 Thread Vinay Sajip
Brett Cannon python.org> writes: > No one is saying we should deprecate % any time soon on strings > themselves or anywhere. This discussion is purely in regards to > argparse and logging to transition *their* APIs over to {} formatting > which would most likely involve some deprecation for *usin

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread MRAB
Antoine Pitrou wrote: MRAB mrabarnett.plus.com> writes: Another possibility: A StringFormat class with subclasses PercentStringFormat, BraceStringFormat, and perhaps DollarStringFormat. Or: A StringFormat class with methods parse_percent_format, parse_brace_format, and parse_dollar_format

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread Brett Cannon
On Sat, Oct 3, 2009 at 11:01, Steven D'Aprano wrote: > On Sun, 4 Oct 2009 01:41:36 am Steven Bethard wrote: >> I thought it might be useful for those who don't have time to read a >> million posts to have a summary of what's happened in the formatting >> discussion. >> >> The basic problem is that

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread Steven D'Aprano
On Sun, 4 Oct 2009 01:41:36 am Steven Bethard wrote: > I thought it might be useful for those who don't have time to read a > million posts to have a summary of what's happened in the formatting > discussion. > > The basic problem is that many APIs in the standard library and > elsewhere support on

Re: [Python-Dev] summary of transitioning from % to { } formatting

2009-10-03 Thread Antoine Pitrou
MRAB mrabarnett.plus.com> writes: > > Another possibility: > > A StringFormat class with subclasses PercentStringFormat, > BraceStringFormat, and perhaps DollarStringFormat. > > Or: > > A StringFormat class with methods parse_percent_format, > parse_brace_format, and parse_dollar_format. Ther

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread MRAB
Mark Dickinson wrote: On Sat, Oct 3, 2009 at 4:41 PM, Steven Bethard wrote: I thought it might be useful for those who don't have time to read a million posts to have a summary of what's happened in the formatting discussion. Definitely useful. Thanks for the summary! [...] * Add a parame

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread MRAB
Steven Bethard wrote: I thought it might be useful for those who don't have time to read a million posts to have a summary of what's happened in the formatting discussion. The basic problem is that many APIs in the standard library and elsewhere support only %-formatting and not {}-formatting, e

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread Mark Dickinson
On Sat, Oct 3, 2009 at 4:41 PM, Steven Bethard wrote: > I thought it might be useful for those who don't have time to read a > million posts to have a summary of what's happened in the formatting > discussion. Definitely useful. Thanks for the summary! [...] > * Add a parameter which declares

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread Barry Warsaw
On Oct 3, 2009, at 11:41 AM, Steven Bethard wrote: I thought it might be useful for those who don't have time to read a million posts to have a summary of what's happened in the formatting discussion. The basic problem is that many APIs in the standard library and elsewhere support only %-forma

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread Antoine Pitrou
> Define "fails": > > >>> "{a} {b} c" % {'a':12} > '{a} {b} c' > > That didn't fail... Ah, my bad. I had completely overlooked that formatting was laxist when faced with unused named parameters. Then we need something smarter, like counting the number of unescaped "%" characters, the number of

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread R. David Murray
On Sat, 3 Oct 2009 at 17:08, Paul Moore wrote: 2009/10/3 Antoine Pitrou : Steven Bethard gmail.com> writes: ? If %-formatting is to be deprecated, the transition strategy here ? is trivial. However, no one has yet written translators, and it is ? not clear what heuristics should be used, e.g.

Re: [Python-Dev] summary of transitioning from % to {} formatting

2009-10-03 Thread Paul Moore
2009/10/3 Antoine Pitrou : > Steven Bethard gmail.com> writes: >> >>   If %-formatting is to be deprecated, the transition strategy here >>   is trivial. However, no one has yet written translators, and it is >>   not clear what heuristics should be used, e.g. should the method >>   just try %-for

Re: [Python-Dev] summary of transitioning from % to { } formatting

2009-10-03 Thread Antoine Pitrou
Steven Bethard gmail.com> writes: > > If %-formatting is to be deprecated, the transition strategy here > is trivial. However, no one has yet written translators, and it is > not clear what heuristics should be used, e.g. should the method > just try %-formatting first and then {}-formatt