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

Steven D'Aprano steve at pearwood.info
Tue Sep 16 00:39:42 CEST 2008


On Tue, 16 Sep 2008 12:39:52 am Fredrik Lundh wrote:
> Nick Coghlan wrote:
> > While it may not make sense to list it in the table itself, having
> > a note on that page that comma is NOT an operator (unlike C), and
> > hence only permitted between expressions as part of another
> > statement or expressions that permits it may not be a bad idea.
>
> better include "=" and augmented assignments as well.
>
> on the other hand, we're talking about a single instance of a
> "someone" here -- it's not like there's any sign that the comma issue
> is something that lots of someones are confused about.

*puts up hand*

I was confused about the role of commas, and totally gobsmacked when I 
discovered that commas make tuples everywhere except when following an 
except statement. (At least that's how I interpreted what I was seeing 
with "try...except A, B, C, e".)

Right or wrong, my mental model is that commas are the tuple operator, 
except in special places where it isn't and you have to use 
parentheses. Well, actually I know the model is wrong *now*, because 
I've read this thread, but until now I would have cheerfully described 
the comma as an operator. Judging by the number of hits on Goggle 
for 'Python "comma operator"', I'm not alone: over 4700 hits for comma 
operator versus 800 for comma separator.



-- 
Steven


More information about the Python-Dev mailing list