missing 'xor' Boolean operator

Wayne Brehaut wbrehaut at mcsnet.ca
Wed Jul 15 15:55:08 EDT 2009


On Wed, 15 Jul 2009 11:51:44 -0700 (PDT), Mark Dickinson
<dickinsm at gmail.com> wrote:

>On Jul 15, 7:29 pm, Wayne Brehaut <wbreh... at mcsnet.ca> wrote:
>> On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson <dicki... at gmail.com> wrote:
>> >I'd also guess that 'xor' would be much less used than 'and' or 'or',
>> >but maybe that's just a reflection of the sort of code that I tend to
>> >write.
>>
>> You're right about that!. It's used everywhere in:
>> [snip examples and references]
>
>Those examples are (almost) all about the *bitwise* xor operator,
>which exists in Python ('^') and, as you point out, has no shortage of
>good uses.  The discussion was about a *logical* xor, to parallel the
>existing 'and' and 'or' operators.

I thought you were saying your program domains didn't include a lot of
requirements for xor in general, rather than just no uses for Boolean
xor--and I'm used to thinking of xor on binary vectors as "Boolean"
anyway so would still have been confused.

The most common non-binary-bit-wise xor is the general "symmetric
difference" of sets, most likely to be useful in list or dictionary
processing or database-like contexts. Please see my suggested use-case
for Steven below.

wayne



More information about the Python-list mailing list