Name is not defined in a list comprehension with multiple loops
<p>I'm trying to unpack a complex dictionary and I'm getting a <code>NameError</code> in a list comprehension expression using multiple loops:</p>

<pre><code>a={
  1: [{'n': 1}, {'n': 2}],
  2: [{'n': 3}, {'n': 4}],
  3: [{'n': 5}],
}
good = [1,2]
print [r['n'] for r in a[g] for g in good]
# NameError: name 'g' is not defined
</code></pre>