What is the operator precedence when writing a double inequality in Python (explicitly in the code, and how can this be overridden for arrays?)

后端 未结 3 815
悲哀的现实
悲哀的现实 2020-12-18 21:52

What is the specific code, in order, being executed when I ask for something like

>>> 1 <= 3 >= 2
True

If both have equal pr

3条回答
  •  生来不讨喜
    2020-12-18 22:52

    Both have the same precedence, but are evaluated from left-to-right according to the documentation. An expression of the form a <= b <= c gets expanded to a <= b and b <= c.

提交回复
热议问题