geremy condra schrieb:
On Tue, Oct 27, 2009 at 6:46 PM, Georg Brandl g.brandl@gmx.net wrote:
Sturla Molden schrieb:
Why does Python have a bitwise but not a logical xor operator?
How often do you need the xor operator?
- Technically, an operator is *never* needed, as its just syntactic sugar.
Exactly. Therefore it makes sense to select the most often used operations and add syntactic sugar for them. Boolean XOR is not one of them. (The thread linked by Mark enumerates a fair number of equivalent spellings, but the most important thing is that it's impossible to make the "xor" behave equivalent to "and" and "or" in terms of short-circuiting and returning one of the operands.)
- It sure would make crypto code look prettier, as we rely on xor operations extensively.
We *do* have a bitwise xor.
Georg