Does Python need an 'xor' operator?
Grant Edwards
grante at visi.com
Sun Apr 14 00:12:42 EDT 2002
In article <3cb8b86a at news.mhogaming.com>, Ken Peek wrote:
> (not a) ^ (not b)
>
> IMHO, neither the above, nor the future v2.3.x idiom:
>
> bool(a) ^ bool(b)
>
> is as clear as:
>
> a xor b
I agree. Since the other boolean operators are "not" "and"
"or", it would be a bit of a surprise that one doesn't use
"xor". And having to convert a boolean to a "chunk of bits"
first and do a bitwise xor on it is just plain ugly.
OTOH, when I want to do exclusive or, it's pretty much always
the bitwise operation I want.
--
Grant Edwards grante Yow! If I had a Q-TIP, I
at could prevent th' collapse
visi.com of NEGOTIATIONS!!
More information about the Python-list
mailing list