How can I format currency using python template strings? My goal is to generate the following string:
'Hello Johnny. It is $10'
I've tried the following:
from string import Template
d = {'name': 'Johnny', 'cost': 10}
Template('Hello ${name}. It is ${cost}').substitute(d)
# 'Hello Johnny. It is 10'
Template('Hello ${name}. It is $${cost}').substitute(d)
# 'Hello Johnny. It is ${cost}'
Template('Hello ${name}. It is $$cost').substitute(d)
# 'Hello Johnny. It is $cost'