[mod_python] Syntax error in generated psp code

Graham Dumpleton grahamd at dscpl.com.au
Thu Jan 26 14:59:34 EST 2006


On 27/01/2006, at 5:08 AM, Dan Eloff wrote:

> Could someone please tell me why this:
>
> <% for href, text in vars.main_menu: %>
> 	<li><a href="<%=href%>"><%=text%></a></li>
> <% # End of menu loop			
> %>
>
> Is turuend into:
> for href, text in vars.main_menu: ;req.write(""" ....
>
> With that extra ; right after the loop? It creates a syntax error.
>
> How might I write my psp so as to avoid that?

 From memory, try:

<%
for href, text in vars.main_menu:
     # fake indent
%>
	<li><a href="<%=href%>"><%=text%></a></li>
<%
# end of loop			
%>

If you aren't going to use a tab stop (8 spaces) of indent, you have to
provide additional hinting. Blocks of code is also better off not having
the <% %> on same lines as code.

Graham



More information about the Mod_python mailing list