[Python-ideas] string.Template v2

Victor Stinner victor.stinner at gmail.com
Thu Nov 28 18:53:07 CET 2013


2013/11/28 anatoly techtonik <techtonik at gmail.com>:
> ## Scope of Enhancement
>
> st = 'Hello {{world}}.'
> world = 'is not enough'
> t = Template(string, style='brace')
> t.render(locals())

I'm not sure that I understood correctly your proposition. Do you
suggest to add a new module to the Python module or to enhance the
existing string.Template class?

In my opinion, string.Template alone is almost useless (it's probably
why it is not used). Templates engines are much more powerful: cache
results, loops, apply functions on variables, escape HTML, etc. IMO
it's better to continue to develop templates outside Python stdlib.
When a module enters the Python stdlib, its API is almost frozen
during many years and you must keep the backward compatibility. It can
be a blocker point if you want to enhance your module. It looks like
template engines are moving fast, at least faster than the CPython
stdlib. Template engines are also specific to a domain, especially to
the web. You may need a different template engines for a different
domain. Tell me if I'm wrong.

Well, that's just my opinion. Others may like to enhance
string.Template class to support the "{{name}}" syntax.

--

If you want to include a whole template engine into the Python stdlib,
the proposition should come from the maintainer of the module. We
don't want to have a split (different API, different behaviour)
between the version available in CPython and the version maintained on
PyPI. And the proposition must be a full PEP describing the API,
explain why it's better to get the engine into the stdlib, rationale,
compare with other engines, etc.

Victor


More information about the Python-ideas mailing list