Operator precedence table questions

Ned Batchelder ned at nedbatchelder.com
Sun Feb 16 01:30:06 CET 2014


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

but:

     a < b < c

is not the same as:

     (a < b) < c

-- 
Ned Batchelder, http://nedbatchelder.com




More information about the Python-list mailing list