On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson <dicki...@gmail.com> wrote:
>On Jul 14, 7:25 pm, "Dr. Phillip M. Feldman" <pfeld...@verizon.net> >wrote: >> Current Boolean operators are 'and', 'or', and 'not'. It would be nice to >> have an 'xor' operator as well. > >Hmm. I don't think 'nice' is sufficient. You'd need to make the case >that it's sufficiently useful to justify adding a new keyword 'xor' to >the language; I suspect that would be an uphill struggle. :) === 8< === And for the objects for which it *is* sufficiently useful (sets) the xor operator ^ is available: >>> cheese = set(['cheddar', 'limburger', 'stilton']) >>> stinky = set(['skunk', 'limburger', 'stilton', 'polecat', 'doggy-doo', >>> 'civet']) >>> nasty = set(['doggy-doo', 'polecat', 'limburger', 'Perl']) >>> cheese & stinky # stinky cheese set(['limburger', 'stilton']) >>> cheese ^ stinky # either cheese or stinky but not both set(['doggy-doo', 'civet', 'polecat', 'skunk', 'cheddar']) >>> cheese ^ stinky ^ nasty # in an odd number of these sets (1 or 3) set(['civet', 'cheddar', 'Perl', 'limburger', 'skunk']) wayne -- http://mail.python.org/mailman/listinfo/python-list