Is it possible to use Python\'s str.format(key=value) syntax to replace only certain keys.
Consider this example:
my_string = \'Hello {n
Python3.2+ has format_map which lets you do this
>>> class D(dict):
... def __missing__(self, k):return '{'+k+'}'
...
>>> my_string = 'Hello {name}, my name is {my_name}!'
>>> my_string.format_map(D(name='minerz029'))
'Hello minerz029, my name is {my_name}!'
>>> _.format_map(D(my_name='minerz029'))
'Hello minerz029, my name is minerz029!'
Now it's not necessary to add extra {}, only the keys you provide to D will be substituted
As @steveha points out, if you are on an older Python3 you can still use
my_string.format(**D(name='minerz029'))