Allowing zero-dimensional subscripts

Terry Reedy tjreedy at udel.edu
Fri Jun 9 04:53:35 EDT 2006


<spam.noam at gmail.com> wrote in message 
news:1149832139.948242.64160 at f6g2000cwb.googlegroups.com...
> The question is, is this,
> conceptually, the feature that allows you to ommit the parentheses of a
> tuple in some cases.

To repeat: tuples are defined by commas.  There are no 'parentheses of a 
tuple', except for empty tuples, to be omitted.  Consider: a+b is a sum; in 
(a+b)*c, the sum is parenthesized to avoid confusion with a+b*c.  Like 
other expressions, tuples are parenthesezed when needed to avoid similar 
confusion.  So (1,2)+(3,4) needs parens because 1,2+3,4 would be something 
different.  In both examples, parens are used to reverse normal precedence 
relations.

Terry Jan Reedy






More information about the Python-list mailing list