I have a template in which some variables shall be replaced. As the template shall be for C-source code, it contains brackets {
and }
. The python formatter, which is used for replacing is breaking on these brackets. Is there any way to escape those brackets that shall be kept in the result text?
Minimum example:
template = """
Here is some text
Here is something to insert {name}
And here is a {
and later there is a }
"""
settings = {'name': "John"}
print( template.format(**settings) )
My target result is:
Here is some text
Here is something to insert John
And here is a {
and later there is a }
The actual result is a python error:
Traceback (most recent call last):
File "minimum.py", line 9, in <module>
print( template.format(**settings) )
KeyError: ' \n and later there is a '