On 2007-11-26, Boris Borcic <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>> def xor(a, b):
>>      return a and not b or b and not a
>
>
> >>> from operator import xor
> >>> help(xor)
> Help on built-in function xor in module operator:
>
> xor(...)
>      xor(a, b) -- Same as a ^ b.

Which isn't the same thing:

------------------------------testit.py------------------------------
import operator

def xor(a,b):
    return a and not b or b and not a

print xor(1,3), operator.xor(1,3)
------------------------------testit.py------------------------------

$ python testit.py
False 2

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

-- 
Grant Edwards                   grante             Yow! My haircut is totally
                                  at               traditional!
                               visi.com            
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to