python : template var without space

python, templates

Solution

Use curly braces around the pattern:

Template("a small number : ${number}e6")

Result:

>>> Template("a small number : ${number}e6").substitute(number=5)
'a small number : 5e6'

Problem

in python, I try use templates ``` from string import Template s = Template("hello $world") print s.substitute(world="Stackoverflow") ``` ok, but, In the template I need concatenate a string without space, example ``` s = Template("a small number : $number e6") print s.substitute(number=5) ``` I need `a small number : 5e6` as output, without white space between 5 and e6.

Original source