Grant Edwards <[EMAIL PROTECTED]> wrote:
   ...
> I like the solution somebody sent me via PM:
> 
> def toggle():
>     while 1:
>         yield "Even"
>         yield "Odd"

I think the itertools-based solution is more elegant:

toggle = itertools.cycle(('Even', 'Odd'))

and use toggle rather than toggle() later; or, just use that
itertools.cycle call inside the expression instead of toggle().


Alex
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to