missing 'xor' Boolean operator
Chris Rebert
clp2 at rebertia.com
Tue Jul 14 15:43:42 EDT 2009
On Tue, Jul 14, 2009 at 11:47 AM, Mark Dickinson<dickinsm at gmail.com> wrote:
> On Jul 14, 7:25 pm, "Dr. Phillip M. Feldman" <pfeld... at 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. :)
>
> I'll just note that:
>
> (1) It's easy to emulate xor: 'x xor y' <-> bool(x) != bool(y)
Using the xor bitwise operator is also an option:
bool(x) ^ bool(y)
Cheers,
Chris
--
http://blog.rebertia.com
More information about the Python-list
mailing list