title: python statement: (k,v) for k,v
body: <p>I use pycharm with python 2.7</p>
  
  <p>For a dictionary param, I try to use the following two statements:</p>
  
  <pre><code>   *print "%s=%s" %(k,v) for k,v in param.items()
      print ["%s=%s" %(k,v) for k,v in param.items()]*
  </code></pre>
  
  <p>The first line has a syntax error because the k,v can't be resolved, but the second line could be executed normally. How should I understand that, and how can the IDE find k,v for the second line?</p>
  
  <p>I know the second line belongs to list comprehension, but it makes me confused because parts of a valid statement is invalid, so this kind of statement can be used only within a list?</p>