Poor man's python templating - what should I worry about?
After churning through the various templating package, I now just use triple quoted strings and dictionary substitution. I never have to read docs, and never forget how to use it. Also, I never run into cases that break the system.
myhtml = '''
<html><body>
<p>%(firstname)s</p>
<p>%(lastname)s</p>
</body></html>
''' % {'firstname':'john','lastname':'doe'}
It's not pretty, but I feel less hindered by this approach. I'm curious what people think the main downsides of this are...
3 comments
[ 1.5 ms ] story [ 20.6 ms ] threadI fixed this by simply using string replace(), and suitably unique replace tokens.
(Then again, I program in Notepad, preferring it for aesthetic reasons over Emacs, so go figure :-)
http://docs.python.org/lib/defaultdict-objects.html