I have a long string (a "template") containing "replacement points" in the form of %MARK% (there can be more occurences in the string for a single given marker too). I want to replace these markers, controlled by a Python dictionary (it does not contain the % signs for markers), like:
rep_dict = { "TITLE": "This is my title", "CONTENT": "Here it is the content" }
The problem: simple call of replace() method one by one is not a good solution: the previous replacement may contain one of these marks, which then must not be replaced!
The solution should be fast enough, since I have large templates, and I need to replace many of them within a big loop. I have a very ugly and long implementation with many find()'s, counting offsets in the original string during the replacament process, etc. I have the hope that there is a much nicer, more compact, and quicker solution.
%(MARK)or{MARK}? The%...notation is deprecated, and the{...}one requires him to double plain-text curly braces:{{these braces make it to the output string}}, {these do not}.%(btw it has no date of disappearance yet, despite what was said) butstring.Template. I reedited and completed my comment