Replace text with value form dictionary (regexp)
Mirko Zeibig
mirko-lists at zeibig.net
Wed Mar 3 09:40:36 EST 2004
Jean-Pierre Bergamin said the following on 03/03/2004 03:09 PM:
> 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");
Hm, why don't you just use the "normal" pyformat-replacements ala
"%(KEY)FORMAT":
print """
<html>
<head>
<title>%(title)s</title>
</head>
<body>
<h1>%(title)s</h1>
I got %(amount)0.2f dollars
</body>
</html>
""" % { 'title': 'My account', 'amount': 3.5 }
Regards
Mirko
--
More information about the Python-list
mailing list