On Oct 18, 3:48 pm, Iain King <[EMAIL PROTECTED]> wrote:
> On Oct 18, 2:29 am, Grant Edwards <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 2007-10-17, Debajit Adhikary <[EMAIL PROTECTED]> wrote:
>
> > > # Start of Code
>
> > > def evenOdd():
> > >     values = ["Even", "Odd"]
> > >     state = 0
> > >     while True:
> > >         yield values[state]
> > >         state = (state + 1) % 2
>
> > I'd replace the last line with
>
> >           state ^= 1
>
> > to save a couple instructions, but I spend too much time
> > working with micoroprocessors running on clocks measured in the
> > KHz.
>
> > There are probably other more Pythonic ways...
>
> I always use:
>
>            state = 1 - state
>
> for toggles.  I doubt it's much more pythonic though :)
>
> Iain

why not do
state = not state
?

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

Reply via email to