xor operator?

Thomas Wouters thomas at xs4all.net
Fri Jan 26 09:04:20 EST 2001


On Fri, Jan 26, 2001 at 01:59:24PM +0000, Erik de Castro Lopo wrote:
> Def P wrote:

> > I notice that there doesn't seem to be a boolean xor operator in Python. Does
> > someone know the reasons behind this?

>     Python 2.0 (#6, Jan 26 2001, 11:27:57) 
>     [GCC 2.95.2 19991024 (release)] on linux2
>     Type "copyright", "credits" or "license" for more information.
>     >>> "%x" % (0x2^0xF)
>     'd'
>     >>> "%x" % (0xd^0xF)
>     '2'

> Seems to work for me :-).

He wanted a *boolean* xor operation. That is, like 'a and b', but return
true if *either* a or b (not both, just one of them) are true. The '^'
operator is the bitwise xor operation.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list