python - py:choose with list of strings -
I am trying to select a statement inside a loop, I have to populate a table like this:
& lt; Tr py: for = "i in category (0,25)" & gt; & Lt; Py: select my_list [i] = '0' & gt; & Lt; Py: When my_list [i] = '0' & gt; & Lt; Td> Not OK & Lt; / Py: When & gt; & Lt; Py: Otherwise & gt; & Lt; TD & gt; OK & lt; / TD & gt; & Lt; / Py: Otherwise & gt; & Lt; / Py: Select & gt; ... ... & lt; / Tr & gt;
Let me line & lt; There is an error on py ... select ... & gt;
:
TemplateSyntaxError: Not good - Certified (invalid token): Line ...
but I do not understand how Use the Select Statement! If I feel like C-like (and it seems more logical) I just have to write:
Not OK & Lt; / Py: When & gt; & Lt; Py: Otherwise & gt; & Lt; TD & gt; OK & lt; / TD & gt; & Lt; / Py: Otherwise & gt; & Lt; / Py: Select & gt; ... ... & lt; / Tr & gt;
Can you help me? Oh, there is a list of string my_list
again, if the string 0
is fine for me, everything else is fine.
In PA:
, select Ith
Instead of reaching the contents of my_list, instead of i
from the limit is set to int
I think this is an inappropriate example, and you Ith < Trying to use the value of / code> the
my_list
. In this situation, you should just repeat instead of using my_list
instead of using the category
.
Here is an existing example that your current methods are within error :
automatically:
import from genshi.template Markup template templates_text = "" "& lt; html xmlns: py =" http: // genshi .eggewall.org "/" & gt; & lt; tr py: for = "index in category (0, 25)" & gt; ; & Lt; py: test = "index" & gt; & lt; py: when index = "0" & gt;; & lt; td> $ {index} is not correct & lt; / td & gt; ; & Lt; / py: When & gt; & lt; py: Otherwise & gt; & lt; td & gt; $ {index} is OK & lt; / td & gt; & lt; / py: Otherwise & gt; ; & Lt; / py: select & gt; & lt; / tr & gt; & lt; / html & gt; "" "tmpl = Ma Contact template (template_text) stream = tmpl.generate () print (stream .reader ('xhtml'))
However, you might see list_of_ints
to My_list
should be changed and it should be repeated directly. Pointer address of each item from my_list
: P> < Code> genshi.template import markup template templates_text = "" "& lt; html xmlns: py =" http://genshi.edgewall.org/ "& gt; & lt; tr py: for =" (Index Gt; & Gt; & lt; td & gt; Index = $ {index}, item = $ {contact = $ {index}, & gt; item} is not OK & lt; / td & gt; & lt; / py: When & gt; & lt; py: Otherwise & gt; & lt; td> $ {index}, item = $ {item} is ok < ; & Lt; / py: select & gt; & lt; / tr & gt; & lt; / html & gt; "" "" "tmpl = Markup Tem Late (template_text) stream = tmpl.generate (list_of_ints = range (0, 25)) print (stream.render ('xhtml')) Of course, these examples are from a Python interpreter You can easily modify it to work with your setup.
HH
Comments
Post a Comment