ID EN
Built-in Types

format_map

Python 3.11

Similar to str.format(**mapping), except that mapping is used directly and not copied to a dict. This is useful if for example mapping is a dict subclass:

Syntax

PYTHON
str.format_map(mapping)

Examples

Example 1
PYTHON
>>> class Default(dict):
...     def __missing__(self, key):
...         return key
...
>>> '{name} was born in {country}'.format_map(Default(name='Guido'))
'Guido was born in country'

See Also

dict