tuples in conditional assignment

George Trojan george.trojan at noaa.gov
Mon Nov 23 22:25:48 EST 2015


The following code has bitten me recently:

 >>> t=(0,1)
 >>> x,y=t if t else 8, 9
 >>> print(x, y)
(0, 1) 9

I was assuming that a comma has the highest order of evaluation, that is 
the expression 8, 9 should make a tuple. Why this is not the case?

George





More information about the Python-list mailing list