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

Ian Bicking ianb at colorstudy.com
Wed Apr 5 05:31:44 CEST 2006


Barry Warsaw wrote:
> On Apr 4, 2006, at 7:17 PM, Ian Bicking wrote:
>> These don't quite work with string.Template, because ${...} has the 
>> same content constraints that $... has, so you can't easily put 
>> extended expressions in there.  I could have sworn I opened an SF bug 
>> on this, but it appears not.  But that's an aside.
>>
> 
> I may be misunderstanding, but the contents of ${...} is pretty flexible 
> because you control the regular expression that matches the 
> substitution.  Heck, you can even use something other than $ delimiters 
> if you want.

The problem is that the regex for the ... in $... and ${...} is the 
same, so if you want to match ${foo:bar}, you also have to match 
$foo:bar.  I'd rather leave $foo constrained to simple variable names, 
and require ${} for anything more complex.

I got around that with LaxTemplate at the bottom of this file: 
http://svn.pythonpaste.org/Paste/Script/trunk/paste/script/copydir.py


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


More information about the Python-3000 mailing list