I have a long string that contains placeholders, that should be replaced with some data.
strOut = "text text {{ }} text text {{ }}"
with this pattern
pattern = r'\{{(.+?)\}}'
It's easy for me to do something like this
pattern.sub(self.mymethod, strOut)
where mymethod will be called for substitution. It actually works great. However, this is the problem now. I need to replace all placeholders in string with the values from a list. For example, this is the string again:
strOut = "text text {{ }} text {{ }} text"
It will always have undetermined number of placeholders. If I also have a list of let's say 2 values
myList = [2, 3]
I need a way to inject these values into placeholders, and end up with this
"text text 2 text 3 text"
Number of values in a list and number of placeholder will always be the same, I just don't know in advance how many there will be.