I use the built in ‘sum’ function in a web.py templator template and I get the following error:
global name 'sum' is not defined
Source code is below:
$if profs:
$for prof in profs:
$sum([1, 2, 3])
I can use ‘sum’ just fine at a Python REPL in the terminal.
What could be the issue?
Thanks,
Jacob
Add the functions in a dict and pass as the globals argument to render:
Then in your template you can just use it: