You are just defining a tuple, it's not that math operators supports commas. What python is doing there, is assuming you are doing a tuple (because of the commas), so it evaluate each value between the comas, and then store it to the tuple. Not a thing about primitive math operator, it's just how python interprets commas.
You could do 1,"a","a"+"b",2+5
, and that would give you the tuple (1, "a", "ab", 7)
.
An easy and simplist way of giving an answer is: If python finds a comma in your code, it assumes you put it there for separating data. Then, if he finds 1, 1+1
, you are giving two data, a number one, and an expresion 1+1. Python evaluates the expresion and says "Oh, its 2". Then, he returns you the (1,2)
tuple.
Im not an expert at python compiler, so don't rely 100% on my answer, but I'm quite sure that's the reason.
(2, 10, (2/2))
,(2, 10, (2*2))
, and(2, 10, (2%2), 3)
. – 0x5453 Feb 9 '18 at 19:13