eof

ZeD vito.detullio at gmail.com
Mon Nov 26 11:14:08 EST 2007


Grant Edwards wrote:

> The user-defined xor is operates on "logical" boolean values.
> The one in the operator module is a bitwise operator.

def xor(a, b):
    return bool(a) ^ bool(b)

seems more explicit to me.
maybe, to make "more" explicit (too much, onestly...)

from operator import xor as bitwise_xor

def logical_xor(a, b):
    return bitwise_xor(bool(a), bool(b))

-- 
Under construction



More information about the Python-list mailing list