1 a = 4 2 3 def f(x): 4 def g(): 5 y = 2 # used to initialise h 6 def h(z): 7 return x, y, z, a 8 y = 5 # Python uses this value directly from g in h 9 return h 10 return g 11 12 result = f(1)()(3) 13 assert result == (1, 2, 3, 4) # (1, 5, 3, 4) in Python