Christoph Zwerschke wrote:
> <tr py:for="i in range((len(pics)+1)//2)">
> <td><img src="${pics[2*i]}" /></td>
> <td><img py:if="len(pics)>2*i+1" src="${pics[2*i+1]}" /></td>
> </tr>
Sorry, that was a bit unpythonic. Using the step parameter of range as
suggested by Paul is better:
<tr py:for="i in range(0, len(pics), 2)">
<td><img src="${pics[i]}" /></td>
<td><img py:if="len(pics)>i+1" src="${pics[i+1]}" /></td>
</tr>
Here is a solution for an arbitrary number of cols:
<table py:if="pics">
<tr py:for="i in range(0, len(pics), cols)">
<td py:for="j in range(cols)">
<img py:if="len(pics)>i+j" src="${pics[i+j]}" />
</td>
</tr>
</table>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---