[PLEASE SEE NOTE BELOW]
Also this should work:
x += (0,0),
NOTE:
this is unsafe!! Thanks to Amadan and aIKid for the great discussion.
As Amadan pointed out, this specific case will work only because the assignment operator +=
has lower priority than ,
, so by the time the two tuples are joined, (0,0),
has already become ((0,0),)
.
But if you try:
((1, 2), (3, 4)) + (5, 6),
the result will be a messy
(((1, 2), (3, 4), 5, 6),)
because +
has higher priority than ,
, so the numbers 5 and 6 are joined to the tuple separately!
There intermediary stage is then ((1, 2), (3, 4), 5, 6),
and finally this tuple with a final ,
is "corrected" to give (((1, 2), (3, 4), 5, 6),)
.
Take-home message: using the notation (5, 6),
is not safe because it being "corrected" to ((5, 6),)
might have lower priority than other operators.