Pregunta

How do I take the 'log' of a particular variable "testvar" in a Mako template? Assume that testvar is already a number. It does not appear clear in the documentation as to how one would do this.

¿Fue útil?

Solución

You can import math inside the template, then call math.log:

>>> from mako.template import Template
>>> print Template("<%import math%>${math.log(testvar)}").render(testvar=2)
0.69314718056
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top