missing 'xor' Boolean operator

Jean-Michel Pichavant jeanmichel at sequans.com
Wed Jul 15 15:05:16 EDT 2009


Miles Kaufmann wrote:
>
> On Jul 15, 2009, at 1:43 PM, Jean-Michel Pichavant wrote:
>
>> Hrvoje Niksic wrote:
>> [snip]
>>> Note that in Python A or B is in fact not equivalent to not(not A and
>>> not B).
>>>
>> >>> l = [(True, True), (True, False), (False, True), (False, False)]
>> >>> for p in l:
>> ...     p[0] or p[1]
>> [snip]
>> Did I make twice the same obvious error ?
>
>
> Try again with:
>
> l = [('foo','bar'), ('foo', ''), ('', 'bar'), ('', '')]
>
> -Miles
>
Didn't know that.
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 ?

Let's play again
False or 'foo' => 'foo'
False and 'foo' => False

So funny. I would have expected boolean operators to return a boolean 
value. I should have read the f*** manual (this is an anticipated RTFM 
counter-attack). Anyway Miles, thanks for the update.

JM




More information about the Python-list mailing list