Trivial string substitution/parser
josiah.carlson at sbcglobal.net
Mon Jun 18 06:18:03 CEST 2007
> On Sun, 17 Jun 2007 11:00:58 +0000, Duncan Booth wrote:
>> The elegant and lazy way would be to change your specification so that $
>> characters are escaped by $$ not by backslashes. Then you can write:
>>>>> from string import Template
> Thanks, however, turns out my specification of the problem was
> incomplete: In addition, the variable names are not known at compilation
You mean at edit-time.
>>> t.substitute(variable1="hello", variable2="world")
Can be replaced by...
...as per the standard **kwargs passing semantics.
More information about the Python-list