missing 'xor' Boolean operator
nobody at nowhere.com
Thu Jul 16 22:25:50 CEST 2009
On Thu, 16 Jul 2009 11:06:54 +0200, Jean-Michel Pichavant wrote:
>>> So if I resume:
>>> - not 'foo' => False
>>> - 'foo' or 'foo' => 'foo'
>>> I may be missing something, but honestly, Guido must have smoked some
>>> heavy stuff to write such logic, has he ?
>> Several languages (e.g. Lisp, Bourne shell) behave the same way, i.e. "or"
>> returns the first element which is considered true while "and" returns the
>> last element provided that all preceding elements are considered true.
> Ok then, why "or" does not return True, if the first element is
> considered True ?
If the first element is true, returning the first element is returning
> Why returning the element itself. Any reason for that ?
Why not? Where is the benefit in collapsing all true values to True? You
can convert values to True/False with bool(), but the conversion cannot be
It only makes a difference if you are interested in the representation
rather than the value. Do you normally test for equality with "is" or "=="?
More information about the Python-list