Named placeholders
suggest changeFormat strings may contain named placeholders that are interpolated using keyword arguments to format.
Using a dictionary (Python 3.2+)
>>> data = {'first': 'Hodor', 'last': 'Hodor!'}
>>> '{first} {last}'.format_map(data)
'Hodor Hodor!'
str.format_map allows you to use a mapping without unpacking it first. Lookups go through that mapping, so it does not have to be a dict.
Without a dictionary:
>>> '{first} {last}'.format(first='Hodor', last='Hodor!')
'Hodor Hodor!'
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents