Samuel wrote: > 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 > time.
You mean at edit-time. >>> t.substitute(variable1="hello", variable2="world") Can be replaced by... >>> t.substitute(**vars) ...as per the standard **kwargs passing semantics. - Josiah -- http://mail.python.org/mailman/listinfo/python-list