I'm trying to automatically generate input files for a certain program. They are usually quite "long" (50-100 lines). I came across the Template()
function, which really is perfect for my case.
from string import Template
temp = Template('Very long string with \
multiple lines. \
value = $val')
I need to change/define about 10 values and this can be done easily via:
inp = tmp.substitute(val='5')
Now, when I try to write "inp" to a file, there are no line breaks. I get that it comes from the '\'. In fact I tried with '\n' before, but then the Template function yields an error ("SyntaxError: EOL while scanning string literal"). Do you have some suggestions how to handle this issue?