from string import Template

t = Template('${village} folk send $$10 to $cause')
tstr = t.substitute(village = 'Nottingham', cause = 'the ditch fund')
print(tstr)

# safe_substitute() will leave placeholders unchanged if data is missing
t2 = Template('Return the $item to $owner')
t2str = t2.safe_substitute({'item': 'unladen swallow'})
print(t2str)
1e65fa03bfa1987d31c286803b5b10e57f571096
<mask token>

<mask token>
print(tstr)
<mask token>
print(t2str)

<mask token>
t = Template('${village} folk send $$10 to $cause')
tstr = t.substitute(village='Nottingham', cause='the ditch fund')
print(tstr)
t2 = Template('Return the $item to $owner')
t2str = t2.safe_substitute({'item': 'unladen swallow'})
print(t2str)

from string import Template
t = Template('${village} folk send $$10 to $cause')
tstr = t.substitute(village='Nottingham', cause='the ditch fund')
print(tstr)
t2 = Template('Return the $item to $owner')
t2str = t2.safe_substitute({'item': 'unladen swallow'})
print(t2str)

from string import Template

t = Template('${village} folk send $$10 to $cause')
tstr = t.substitute(village = 'Nottingham', cause = 'the ditch fund')
print(tstr)

# safe_substitute() will leave placeholders unchanged if data is missing
t2 = Template('Return the $item to $owner')
t2str = t2.safe_substitute({'item': 'unladen swallow'})
print(t2str)