Some time ago I thought that the tuple constructor is a pair of parentheses () .
Example:
>>> (1, ) (1, ) >>> type((1, )) <type 'tuple'> >>> t = (1, ) >>> type(t) <type 'tuple'>
But now I know that it is a comma,.
So, doing the same as above:
>>> 1, (1,) >>> type(1,) <type 'int'>
But if I do this:
>>> type(1,2,3) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: type() argument 1 must be string, not int
This makes sense to me, but:
>>> t = 1,2,3 >>> type(t) <type 'tuple'>
And finally:
>>> type((1,2,3)) <type 'tuple'>
Here's the question: why do we need parentheses in the latter case, if the tuple is just 1,2,3 ?