On 2007-10-18, Gerard Flanagan <[EMAIL PROTECTED]> wrote:
> On Oct 18, 1:55 am, Debajit Adhikary <[EMAIL PROTECTED]> wrote:
>> I'm writing this little Python program which will pull values from a
>> database and generate some XHTML.
>>
>> I'm generating a <table> where I would like the alternate <tr>'s to be
>>
>> <tr class="Even">
>> and
>> <tr class="Odd">
>>
>> What is the best way to do this?
>>
>
>
> from itertools import izip
>
> def toggle(start=True):
> flag = start
> while 1:
> flag = not flag
> yield flag
I like the solution somebody sent me via PM:
def toggle():
while 1:
yield "Even"
yield "Odd"
--
Grant Edwards grante Yow! Are we THERE yet?
at
visi.com
--
http://mail.python.org/mailman/listinfo/python-list