[Python-Dev] Issues with PEP 3101 (string formatting)
g.brandl at gmx.net
Sun Jun 24 11:09:40 CEST 2007
Guido van Rossum schrieb:
> Those are valid concerns. I'm cross-posting this to the python-3000
> list in the hope that the PEP's author and defendents can respond. I'm
> sure we can work something out.
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
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
More information about the Python-Dev