xor operator?

Alex Martelli aleaxit at yahoo.com
Fri Jan 26 12:25:08 EST 2001


"Hans Nowak" <ivnowa at hvision.nl> wrote in message
news:mailman.980527355.22048.python-list at python.org...
    [snip]
> I found Python's behavior very confusing at first -- 'and' and 'or' that
> return something else than 0 and 1? I've come to like it now, but
> apparently haven't fathomed everything of it.

It's actually pretty useful IMHO.  I miss it in C, which lets me USE
non-booleans as true/false, but whose && and || operators do not RETURN
the argument-value...

> > (not not x)^(not not y)
> >
> > which is just about as obvious as 'x xor y'.

Incidentally, (not x)^(not y) is shorter and also equivalent:-).


Alex






More information about the Python-list mailing list