ID EN
String

safe_substitute

Python 3.11

Like substitute(), except that if placeholders are missing from mapping and kwds, instead of raising a KeyError exception, the original placeholder will appear in the resulting string intact. Also, unlike with substitute(), any other appearances of the $ will simply return $ instead of raising ValueError.

Syntax

PYTHON
safe_substitute(mapping={}, /, **kwds)

See Also

substitute() KeyError substitute() ValueError safe_substitute()