Skip to content
Myr

document chained pow order

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 99daa2a · Browse files · 1 file+13 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−2 removed

  • other:+13 added−2 removed

1 file+13 added−2 removed

modified:docs/templates.rst+13 added-2 removed
1342 unmodified lines
1343 return ``4``. This can also be used to repeat a string multiple times.1344 ``{{ '=' * 80 }}`` would print a bar of 80 equal signs.13451346``**``1347 Raise the left operand to the power of the right operand. ``{{ 2**3 }}``1348 would return ``8``.1347 Raise the left operand to the power of the right operand.1348 ``{{ 2**3 }}`` would return ``8``.13491350 Unlike Python, chained pow is evaluated left to right.1351 ``{{ 3**3**3 }}`` is evaluated as ``(3**3)**3`` in Jinja, but would1352 be evaluated as ``3**(3**3)`` in Python. Use parentheses in Jinja1353 to be explicit about what order you want. It is usually preferable1354 to do extended math in Python and pass the results to ``render``1355 rather than doing it in the template.13561357 This behavior may be changed in the future to match Python, if it's1358 possible to introduce an upgrade path.135913601361Comparisons1362~~~~~~~~~~~13631364``==``
541 unmodified lines