I have template strings with named arguments (for ex. msg = "{a} {b} {c}"
) and series of functions returning results of some statistical calculations in dictionaries. I want to use these dictionaries to fill templates. However, there is a problem. The exact number of the arguments in the template is not as same as in the dictionary; thus, I can not use simple msg.format(**result)
. Is there a way to overcome this problem, keeping unused format-blocks for further use?
This is what I have:
msg.format(a=1,b=2) -> KeyError: 'c'
This is what I want:
msg.format(a=1,b=2) -> "1 2 {c}"