I'm trying to understand python better and the lack of parentheses can be a bit confusing for some reason.
how is (not a < b < c)
evaluated? Is it (not a) < b < c
? or not (a < b < c)
?
According to the reference manual, does not
have a lower or higher precedence than <
? I'm assuming operators with higher precedence evaluate before those with lower, right? I feel like I need someone to break out the sock puppets right now.
According to the Python 2.4 reference manual not and comparisons have a different precedence. Then in the Python 2.7 reference manual not and comparisons have the same precedence.
If i'm not mistaken not a < b < c
will have varying results depending on the version of python. Would someone please share how this statement is evaluated?
I'm sticking with not (a < b < c)
What you're seeing in the 2.7 manual is all relational operators, including not in
and is not
, at the same precedence; boolean not
is still one level lower in precedence and as such the relational comparison happens first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With