Non-web-based templating system
Brett g Porter
bgporter at acm.org
Fri Apr 28 09:09:31 EDT 2006
Diez B. Roggisch wrote:
> qscomputing at gmail.com wrote:
>
> Maybe the built-in string interpolation is sufficient?
>
> print "Hello %(name)s" % dict(name="Peter Pan")
Or in recent pythons, the built-in string templating system (see
http://docs.python.org/lib/node109.html)
>>> from string import Template
>>> d = dict(name="Barney")
>>> s = Template("Hello $name")
>>> s.substitute(d)
'Hello Barney'
More information about the Python-list
mailing list