from string import Template s = Template('A $thing must never $action.') d = { 'thing': 'gentleman', 'action': 'show his socks' } s.substitute(d) print s