Bitten by my C/Java experience
Terry Reedy
tjreedy at udel.edu
Mon May 4 16:06:29 EDT 2015
On 5/4/2015 1:43 PM, Ian Kelly wrote:
> * () is a zero-element tuple, and (a, b) is a two-element tuple,
> but (a) is not a one-element tuple. Tuples are created by commas, not
> parentheses, so use (a,) instead.
Which means that a, and a,b (or a,b,) are 1 and 2 element tuples
respectively. Except for empty tuples, parentheses are optional unless
needed to fence off the tuple from surrounding code (which happens to be
most of the time, but not always). A trailing comma is prohibited for
zero element tuples, required for one element tuples, and optional for
multiple element tuples.
--
Terry Jan Reedy
More information about the Python-list
mailing list