
On 2009-10-27 18:07 PM, geremy condra wrote:
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?
1) Technically, an operator is *never* needed, as its just syntactic sugar. 2) It sure would make crypto code look prettier, as we rely on xor operations extensively.
No, it wouldn't. Crypto uses the bitwise xor which we already have an operator for: ^. As I stated in the referenced thread, to me, the most compelling reason there is no "xor" keyword to go with "and" and "or" is that one cannot make an xor that shares the same short-circuiting behavior. Or the behavior of returning one of the operand objects rather than a coerced bool. Without either of those behaviors, there is little benefit to having a keyword operator where a trivial one-liner will suffice. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco