The dis
module in the python helps you to see whats going under the hood
>>> from dis import dis
>>> def bo(a=2,b=3):
... print a,b==2,3
...
>>> dis(bo)
2 0 LOAD_FAST 0 (a)
3 PRINT_ITEM
4 LOAD_FAST 1 (b)
7 LOAD_CONST 1 (2)
10 COMPARE_OP 2 (==)
13 PRINT_ITEM
14 LOAD_CONST 2 (3)
17 PRINT_ITEM
18 PRINT_NEWLINE
19 LOAD_CONST 0 (None)
22 RETURN_VALUE
>>> bo()
2 False 3
>>> def bo(a=2,b=3):
... print a,b==3,2
...
>>> bo()
2 True 2
if we use a,b==3,2
when a=2
and b=3
the tuple `s middle element will
have True value
First a
and b
are pushed onto the stack the popped of the stack and compared with corresponding values and then made into a tuple .
So in effect the comparison is done in the reverse order
So reversing the order of elements provides us a correct value in the resulting tuple
In short
def bo(a=1,b=2,c=3,d=4):
print a,b,c,d==4,3,2,1
bo()
will print
1 2 3 True 3 2 1
So we can access the tuples middle element for correct value