[Python-Dev] ',' precedence in documentation]

Christopher Lee leec at chem.ucla.edu
Sun Sep 14 23:01:15 CEST 2008

> ----- Forwarded message from Guido van Rossum <guido at python.org> -----
> Note that in any case, the 'in' operator binds more tightly than the
> comma: e.g. f(x in y, z) means f((x in y), z).

Exactly the point I was trying to make.  As far as the user's  
concerned, an expression list
can itself be part of an expression;
x in y
is also an expression.  Such expressions can be combined to form  
larger expressions, so it follows logically that you need to know  
which has precedence when *both* occur in an expression, e.g. whether
x in y,z
evaluates as
(x in y),z
x in (y,z)

The page that Fredrik sent you to (http://docs.python.org/ref/exprlists.html 
) doesn't address that question.  I still think the precedence table (http://docs.python.org/ref/summary.html 
) should show that "in" has higher precedence than comma in an  

Can anyone show us "where it is written" in the Python docs that "in"  
has higher precedence than comma, *and* why there is a good reason  
that this information should NOT be included in the precedence table?

-- Chris

Adding comma to the precedence table would also disambiguate  
expressions like:
x and y,z
x,y or z
not x,y

More information about the Python-Dev mailing list