Is it possible to do dynamic string substitution with Python's string.Template ? More precisely I don't want to replace occurrences of identifiers with results of functions, e.g.
from string import Template
f = lambda s: "123"
templateString = """first line: $replaceme
2nd line "$replaceme" """
s = Template(templateString).substitute(replaceme=f)
Instead of evaluating f its string representation is used:
first line: <function <lambda> at 0x7fb0367e3488>
2nd line "<function <lambda> at 0x7fb0367e3488>"
Any ideas how to do substitution with the result of f ?