Question

Anyone know how to format the length of a string with Mako?

The equivalent of print "%20s%10s" % ("string 1", "string 2")?

Was it helpful?

Solution

you can use python's string formatting fairly easily in mako

${"%20s%10s" % ("string 1", "string 2")}

giving:

>>> from mako.template import Template
>>> Template('${"%20s%10s" % ("string 1", "string 2")}').render()
'            string 1  string 2'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top