Albert van der Horst <alb...@spenarnc.xs4all.nl> wrote: >>I guess I never thought about it, but there isn't an 'xor' operator to >>go along with 'or' and 'and'. Must not be something I need very often. > > There is. <> applied to booleans is xor. > Best to get into the habit of using '!=' otherwise you'll find Python 3.x a bit frustrating.
However, that only works if you have exactly two values: both 'and' and 'or' will extend easily to any number of values: >>> True and False and True False >>> False or False or True or False True but using != for 'xor' doesn't extend the same way: >>> False != False != True False You can use 'sum(...)==1' for a larger number of values but do have to be careful that all of them are bools (or 0|1). -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list