In python documentation FAQ part, it says lambda expression begins to capture free variables when the function is called. And it gives an example as follows: