robert.kern at gmail.com
Wed Oct 28 00:18:08 CET 2009
On 2009-10-27 18:07 PM, geremy condra wrote:
> On Tue, Oct 27, 2009 at 6:46 PM, Georg Brandl<g.brandl at 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
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.
"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
More information about the Python-ideas