On Jul 20, 11:34 pm, Ethan Furman <et...@stoneleaf.us> wrote: > Dr. Phillip M. Feldman wrote: > > Suppose that 'xor' returns the value that is true when only one value is > > true, and False otherwise. This definition of xor doesn't have the > standard > > associative property, that is, > > > > (a xor b) xor c > > > > will not necessarily equal > > > > a xor (b xor c) > > > > To see that this is the case, let a= 1, b= 2, and c= 3. > > > > (a xor b) xor c > > > > yields 3, while > > > > a xor (b xor c) > > > > yields 1. So, I'd prefer an xor operator that simply returns True or > False. > > > > Phillip > > > > You are, of course, free to write your version however it makes sense to > you and your team. :) > > Since the 'and' and 'or' already return objects (and objects evaluate to > true or false), then 'xor' should behave likewise, IMO. I expect that > would be the case if it were ever added to the language.
I'm not so sure. Did you ever wonder why the any() and all() functions introduced in 2.5 return a boolean rather than returning one of their arguments? (I did, and I'm still not sure what the answer is.) Mark -- http://mail.python.org/mailman/listinfo/python-list