On this page
  1. string.Template
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

string.Template

Prev: string.Formatter | Up: string
Rel: string.capwords, string.Formatter
Ref: docs.python.org — string.Template
Tags: #public #python3 #stdlib #string


Import

import string
from string import Template

Signature & Overview

string.Template(template)

A string class for supporting $-substitutions.

Methods & Attributes

Usage

import string

tpl = string.Template('Hello $user, balance is ${amount} USD')
assert tpl.safe_substitute(user='Ada') == 'Hello Ada, balance is ${amount} USD'

Gotchas

REPL Inspect

from string import Template
help(Template)

Linked from

Related notes