title: How is the output of this Python expression generated?
body: <p>Could someone explain what the output of this expression is and how it is generated. I know I can put this in IDLE and check the output but I want to learn how to do it manually. Specifically, I would like to know how the print statement is executed step by step. </p>
  
  <pre><code>def f(x):
      return lambda y: (x, y(x))
  def g(y):
      return lambda x: x(y)
  print(g(2)(f)(lambda x:x+1))
  </code></pre>