[Tutor] toggle idiom?

Lindsay Davies Lindsay@pobox.com
Tue, 7 May 2002 22:51:55 +0100


Yes, this will do it for you...

a = a ^ 1

Lindsay


>Hello,
>
>I'm not sure this is a "toggle idiom", but here's what it should do:
>
>if a:
>     a = 0
>else:
>     a = 1
>
>Is there a one-liner that can do this?
>
>- Andrei
>
>--
>Cymbaline: intelligent learning mp3 player - python, linux, console.
>get it at: cy.silmarill.org
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor


--