[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Operator precedence table questions

On 2/15/14 7:18 PM, Chris Angelico wrote:
> http://docs.python.org/3.3/reference/expressions.html#operator-precedence
> """
> Operators in the same box group left to right (except for comparisons,
> including tests, which all have the same precedence and chain from
> left to right...)
> """
> Comparisons, including tests, are all in the same box. Grammatically,
> this wording puzzles me. Everything groups L->R except these, which
> group L->R?

I think the "except" is referring to "group" vs. "chain".  Comparison 
operators don't group left to right, they chain left to right:

     a + b + c

is the same as:

     (a + b) + c


     a < b < c

is not the same as:

     (a < b) < c

Ned Batchelder, http://nedbatchelder.com