ZeD wrote: > 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)) >
I'd prefer bool(a)!=bool(b) or even bool(a) is not bool(b) -- http://mail.python.org/mailman/listinfo/python-list