On Oct 18, 2007, at Oct 18:7:47 AM, Paul Hankin wrote:
On Oct 18, 12:11 pm, "Amit Khemka" <[EMAIL PROTECTED]> wrote:
Why not just use enumerate ?
clvalues = ["Even", "Odd"]
for i, (id, name) in enumerate(result):
stringBuffer.write('''
<tr class="%s">
<td>%d</td>
<td>%s</td>
</tr>
'''
%
(clvalues[i % 2], id, name))
I like this code: straightforward and pragmatic.
Although the itertools is probably the way to go here, I've used the
following construct, especially in two-player games. I like the
readability of it:
value='Even'
other_value='Odd'
for i, (id,name) in enumerate(result):
stringBuffer.write('''
<tr class="%s">
<td>%d</td>
<td>%s</td>
</tr>
''' % (value,id,name)
value,other_value=other_value,value # swap the value
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list