I have the following code in web2py/python:
{{for row in db(db.t_problems.id==db.t_problems(request.args(0))).select(): }}
Which grabs all of the rows, as I need them to be. The rows are actual python results, which when I print them out are:
>>> testFunction(2, 3, 4) True >>> testFunction(2, 1, 4) False >>> legalTriangles(-1, -1, -1) False
(when you do a raw output, this is what you get:)
>>> testFunction(2, 3, 4)\r\nTrue >>> testFunction(2, 1, 4)\r\nFalse >>> legalTriangles(-1, -1, -1)\r\nFalse
What I need to do is remove the >>>, and have the testFunction(X,Y,Z) in one variable result and the True/False in another. I thought this might work, but the loop only strips the \r\n, not puts them in a new variable to work with:
ios = row.f_tests.split('>>>') #results are now the testFunctions without the >>>
for io in ios:
i = io.split("\r\n")
So the result becomes:
testFunction(2, 3, 4)True testFunction(2, 1, 4)False testFunction(-1, -1, -1)False
But what I need is…
func1 = testFunction(2, 3, 4)
res1 = True
func2 = testFunction(2, 1, 4)
res2 = False
So I can put them into a table. Any ideas? Thank you!
In raw python, it would be,
Result:
You should be able to translate it to the template or “view” language of web2py. I see from here that it supports the for-loop.