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

Tim Hochberg tim.hochberg at ieee.org
Wed Apr 5 21:26:46 CEST 2006


Ian Bicking wrote:
> Alex Martelli wrote:
> 
>>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).
> 
> 
> Note that if it takes keyword arguments, but doesn't take a single 
> dictionary-like object (like % and string.Template.substitute do), then 
> you lose any ability to use clever or interesting dictionary-like 
> objects for substitution.
> 

Why doesn't the ** take care of this? To take your example, why doesn't 
this work?

string.Template(pattern).substitute(**EscapingWrapper(**EvalingWrapper(**locals()))

Is it that you feel that adding ** is too much of a syntactic burden, or 
am I just missing something?

Regards,

-tim



More information about the Python-3000 mailing list