Hi there
I want to implement a small templating system where values in angle brackets
should be replaced by the corresponding dicitionary value ("foo {x} bar" ->
"foo 10 bar");
[color=blue][color=green][color=darkred]
>>> d = {}
>>> d["x"] = 10
>>> p = re.compile('{ ( [^}]* ) }', re.VERBOSE)
>>> p.sub(r'd["\1"]','foo {x} bar')[/color][/color][/color]
'foo d["x"] bar'
How can I now put the actual value of d["x"] into the string 'foo d["x"]
bar'?
Thanks for your help.
Regards
James
I want to implement a small templating system where values in angle brackets
should be replaced by the corresponding dicitionary value ("foo {x} bar" ->
"foo 10 bar");
[color=blue][color=green][color=darkred]
>>> d = {}
>>> d["x"] = 10
>>> p = re.compile('{ ( [^}]* ) }', re.VERBOSE)
>>> p.sub(r'd["\1"]','foo {x} bar')[/color][/color][/color]
'foo d["x"] bar'
How can I now put the actual value of d["x"] into the string 'foo d["x"]
bar'?
Thanks for your help.
Regards
James
Comment