checking if two things do not equal None
Rustom Mody
rustompmody at gmail.com
Sat Mar 29 22:54:09 EDT 2014
On Sunday, March 30, 2014 8:09:45 AM UTC+5:30, Roy Smith wrote:
> I have no particular problem with
> x < 2 < y
> because it fits the same pattern. But, if you show me
> a != None != b:
> my brain just goes into overload. Honestly, I don't even know what that
> means. My brain keeps trying to stick a, None, and b on Mrs. Albaum's
> number line and keeps walking into the wall. If you (the editorial you)
> tell me that my failure to grok that expression means I'm not fluent in
> Python, well then, guilty as charged.
<Math Terminology>
A relation that is reflexive antisymmetric and transitive is a partial order
Strict order: Irreflexive asymmetric and transitive
Both are strongly related
For general R (partial) S (strict)
S from R
xSy = xRy ∧ x ≠ y
R from S
xRy = xSy ∨ x=y
</Math Terminology>
For both these chained comparisons are natural
!= is not transitive: 2 != 3 and 3 != 2 ⊬ 2 == 2
So for != chained comparisons are not natural (or IMHO appropriate)
More information about the Python-list
mailing list