awkward lambda function
<p>I cannot find out what <code>key=key</code> does in this simple python code:</p>

<pre><code>for key in dict:
    f = (lambda key=key: print(key))
    print(f())
</code></pre>

<p>The first key in 'key=key' is the name of the argument of the lambda function. The second key is a local variable, in your case the for loop variable. </p>

<p>So, in each iteration a local key variable is defined, then f is defined as a lambda function receiving one argument with a default the same as this local - so when you activate it the print(key) uses this default value.</p>

<p>EDIT:
I should emphasize that in the context of f(), key is the local f argument, not the for loop variable. It just defaults to the value of the loop variable.</p>

<p>EDIT 2: 
I just now noticed idjaw's comment. While I don't think this is an answer, this is how you should have wrote your code.</p>

python