पायथन जंजीरों की तुलना के साथ विशेष चीजें करता है।
निम्नलिखित का मूल्यांकन अलग तरीके से किया जाता है:
x > y > z # in this case, if x > y evaluates to true, then
# the value of y is being used to compare, again,
# to z
(x > y) > z # the parenth form, on the other hand, will first
# evaluate x > y. And, compare the evaluated result
# with z, which can be "True > z" or "False > z"
हालांकि दोनों मामलों में, यदि पहली तुलना है False, तो बाकी के बयान पर ध्यान नहीं दिया जाएगा।
आपके विशेष मामले के लिए,
1 in [] in 'a' # this is false because 1 is not in []
(1 in []) in a # this gives an error because we are
# essentially doing this: False in 'a'
1 in ([] in 'a') # this fails because you cannot do
# [] in 'a'
ऊपर दिए गए पहले नियम को प्रदर्शित करने के लिए, ये कथन हैं जो True का मूल्यांकन करते हैं।
1 in [1,2] in [4,[1,2]] # But "1 in [4,[1,2]]" is False
2 < 4 > 1 # and note "2 < 1" is also not true
अजगर ऑपरेटरों की प्राथमिकता: http://docs.python.org/reference/expressions.html#summary
if a < b < c:और इसे सहज रूप से काम करने देता है