[Python-3000] String formating operations in python 3k

Alex Martelli aleaxit at gmail.com
Wed Apr 5 05:33:36 CEST 2006


On Apr 4, 2006, at 8:12 PM, Bill Janssen wrote:

>> +1 for {} over the $/${} dichotomy -- it's easier to explain, as well
>> as more readable.
>
> Perhaps I'm just allergic to bash/perl/java/ruby syntax, but the more
> I follow this discussion, the more I like the current string
> formatting system :-).
>
> It seems to me that the core of the issue is the current insistence,
> with %(NAME)FORMAT, on a trailing format type which is frequently
> forgotten.  Why not just remove that insistence, and use %(foo) in
> py3k?  Code will break, sure, but we're going to expect that.  If you
> really need to control the presentation, put that information inside
> the parens, as in %(foo:.3f).  But let it default to "s".

OK on the substance, but I still prefer Greg's suggestion for simple  
bracketing (e.g., {}) to any kind of "stropped parentheses" (your % 
(...) as well as Template's ${...}).

As for the % operator, I never liked it -- either a builtin function,  
or even better a method of string objects, is going to be much more  
readable (and my preference would be to have it take optional  
positional arguments, corresponding to {1}, {2}, etc, and optional  
named arguments, corresponding to {name} &c).


Alex



More information about the Python-3000 mailing list