[mod_python] for loop doubt

Mike Looijmans nlv11281 at natlab.research.philips.com
Mon Jan 2 05:20:32 EST 2006


There are several errors, so I'm not surprised that you cannot find it:

- "res" is probably a misspelled "req"
- Indentation is completely wrong
- ending %> after for is probably not what you meant.
- using req.write(...) to output a PSP script?
- invalid colon at end of that line

You probably meant the following:
....
	<select name="dob">
	<%
	for n in range(31):
		req.write("<option>%s</option>" % n)
	# end for
	%>
	</select>
....

This cryptic thing should do the same, but quicker and without indentation:

<%= [("<option>%s</option>" % n) for n in range(31)] %>

--
Mike Looijmans
Philips Natlab / Topic Automation


python eager wrote:
> Hi
>    in python server pages i am using for loop . but it will not work 
> properly. The code will be as follow as :
> <td> Date of Birth </td>
>                      <td>
>                       
>                             <select name="dob">
>                                         <% for n in range(31):   %>
>                                               res.write("<option>" + 
> <%=n%> + "</option>"):
>                                        
>                             </select>                    
>                                     nbsp;       
>                     </td>
>  
> But it will not work. What is the error , i cannt found the error. Would 
> any one have solution please send mail me. Thank You Very much. and also 
> Happy New Year
>  
> Note : very urget for me .reply wanted
>  
> regards
> Python_Eager
>  
> 
> ------------------------------------------------------------------------
> Yahoo! for Good - Make a difference this year. 
> <http://us.rd.yahoo.com/mail_us/taglines/charity/*http://brand.yahoo.com/cybergivingweek2005/> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list