checking if two things do not equal None

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun Mar 30 08:41:36 CEST 2014


Roy Smith wrote:
> But, if you show me
> 
>  a != None != b:
> 
> my brain just goes into overload.

Chained comparisons get weird with not-equal operators.
If you see

   a == b == c

then it implies that a == c, but

   a != b != c

does *not* imply that a != c. At least it doesn't in
Python; I've never seen any mathematicians write that, so
I don't know what they would make of it.

-- 
Greg



More information about the Python-list mailing list