title: Formatting dict keys: AttributeError: 'dict' object has no attribute 'keys()'
body: <p>What is the proper way to format dict keys in string?</p>
  
  <p>When I do this:</p>
  
  <pre><code>&gt;&gt;&gt; foo = {'one key': 'one value', 'second key': 'second value'}
  &gt;&gt;&gt; "In the middle of a string: {foo.keys()}".format(**locals())
  </code></pre>
  
  <p>What I expect:</p>
  
  <pre><code>"In the middle of a string: ['one key', 'second key']"
  </code></pre>
  
  <p>What I get:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;pyshell#4&gt;", line 1, in &lt;module&gt;
      "In the middle of a string: {foo.keys()}".format(**locals())
  AttributeError: 'dict' object has no attribute 'keys()'
  </code></pre>
  
  <p>But as you can see, my dict has keys:</p>
  
  <pre><code>&gt;&gt;&gt; foo.keys()
  ['second key', 'one key']
  </code></pre>