On 2009-10-27 18:07 PM, geremy condra wrote:
On Tue, Oct 27, 2009 at 6:46 PM, Georg Brandlg.firstname.lastname@example.org 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.
- 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.