Coming from Perl
Ryan Ginstrom
software at ginstrom.com
Wed Sep 12 21:14:07 EDT 2007
> On Behalf Of Amer Neely
> I saw that and I guess that is the closest thing. In Perl I can do ..
>
> print <<EndHTML;
> <html>
> <body>
> Hello
> </body>
> </html>
> EndHTML
>>> data = dict(title="Python Rocks!",
content="<p>I heart Python</p>")
>>> template = """<html>
<head>
<title>%(title)s</title>
</head>
<body>
%(content)s
</body>
</html>"""
>>> print template % data
<html>
<head>
<title>Python Rocks!</title>
</head>
<body>
<p>I heart Python</p>
</body>
</html>
>>>
You might also want to check out string.Template
(http://docs.python.org/lib/node40.html), or even move on to one of the
many, many templating languages (Mako, Cheetah, Kid, etc.)
Regards,
Ryan Ginstrom
More information about the Python-list
mailing list