May-11-2019, 04:04 PM
(This post was last modified: May-11-2019, 04:05 PM by Gribouillis.)
I suggest to use mako templates which need a $ before the {}
>>> from mako.templates import Template >>> s = "{et{ev}t}d${foo}}tu^tt${bar}tx}" >>> Template(s).render(foo='hello', bar='world') '{et{ev}t}dhello}tu^ttworldtx}' >>> s = "{et{ev}t}d${foo}}tu^tt${bar**3}tx}" >>> Template(s).render(foo='hello', bar=8) '{et{ev}t}dhello}tu^tt512tx}'Of course, there are still issues if the strings contain many % because this is also a part of mako's syntax.