[Python-3000] [Python-Dev] Issues with PEP 3101 (string formatting)

Talin talin at acm.org
Sun Jun 24 21:51:51 CEST 2007


Georg Brandl wrote:
> Another question w.r.t. new string formatting:
> 
> Assuming the %-operator for strings goes away as you said in the recent blog
> post, how are we going to convert string formatting (which I daresay is a very
> common operation in Python modules) in the 2to3 tool?
> 
> Of course, "abc" % anything can be converted easily.
> 
> name % tuple_or_dict can only be converted to name.format(tuple_or_dict),
> without correcting the format string.
> 
> name % name can not be converted at all without type inference.
> 
> Though probably the first type of application is the most frequent one,
> pre-building (or just loading from elsewhere) of format strings is not so
> uncommon when it comes to localization, where the format string likely
> has a _() wrapped around it.
> 
> Of course, converting format strings manually is a PITA, mainly because it's
> so common.
> 
> Georg

Actually, I was presuming that '%' would stick around for the time 
being, although it might be officially deprecated.

Given that writing a 2to3 converter for format strings would be a 
project in itself, I think it's probably best to remain backwards 
compatible for now.

-- Talin


More information about the Python-3000 mailing list