Imagine a script that receives a string:
http://whatever.org/?title=@Title@¬e=@Note@
...and a list of tokens:
['arg:Title=SampleTitle', 'arg:Note=SampleNote']
What is the most Pythonic way to interpolate those tokens into the string, such that, using the above example, the following is produced:
http://whatever.org/?title=SampleTitle¬e=SampleNote
I've considered:
Loop through the list and, for every string it contains, split out the token name, and do a regex replace on every instance of
@TOKEN_NAME
found; andUse some sort of templating mechanism (similar to what one can do with Ruby's
ERB.template
).