In Python 3, I tried the following code and the result is shown in comments:
f = max
max = min
print(max(3,4)) # ① prints 3
print(f(3,4)) # ② prints 4
print(max == min) # ③ prints True
print(max == f) # ④ prints False
print(min == f) # ④ prints False
I have the following questions:
- I understand the result of ①. It prints
3because the namemaxis now bound to what the build-inminfunction does. Is that right? - For result of ②,
fstill acts as amaxeven though themaxis now actually amin. Is this because that the first line of bindingf = maxactually does not bindfto the namemaxbut rather to the content ofmax? (Somewhat like pass by value as opposed to pass by reference) - For result of ④ and ⑤, why both of them are
False? I thought at least one of them will beTrue.