Template.safe_substitute()
Template.safe_substitute() is a Python method in the String Constants category. Like substitute but leaves missing placeholders unchanged instead of raising KeyError. The syntax is Template.safe_substitute(mapping={}, /, **kwargs). Returns: String. A typical example: Template("$a $b $c").safe_substitute(a=1) # "1 $b $c". A close sibling is string.ascii_letters, which string containing all ASCII letters (both lowercase and uppercase). A close sibling is string.ascii_lowercase, which string containing all lowercase ASCII letters. A close sibling is string.ascii_uppercase, which string containing all uppercase ASCII letters. A close sibling is string.digits, which string containing all decimal digit characters. More about this category: String constants and Template — ascii_letters, digits, punctuation, Template. Related String Constants entries: string.ascii_letters, string.ascii_lowercase, string.ascii_uppercase, string.digits, string.hexdigits, string.punctuation. This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try Template.safe_substitute() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.