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

Ian Bicking ianb at colorstudy.com
Mon Apr 3 06:26:47 CEST 2006


Georg Brandl wrote:
> BTW, has anyone seen string.Template being used somewhere?

I use it from time to time, usually when formatting user-provided 
strings (because "%(foo)s" is not very pleasant or easy-to-explain 
compared to "$foo").  However, I *never* use it internally in code, 
because the overhead of importing string and creating the template far 
outweighs the inconvenience of %-based substitution.  Oh, and I really 
like %r.

I'd personally be very happy if $"$foo" worked, as well as 
"$foo".substitute().  $/shell-style substitution is the norm out in the 
world, not the %/printf style that Python uses; it'd be nice to move 
towards that norm.  string.Template is a bit of a tease that way, since 
it doesn't actually provide a very convenient alternative to the bulk of 
what % is used for.

-- 
Ian Bicking  |  ianb at colorstudy.com  |  http://blog.ianbicking.org


More information about the Python-3000 mailing list