title: Python Dictionary Comprehension
body: <p>Is it possible to create a dictionary comprehension in Python (for the keys)?</p>
  
  <p>Without list comprehensions, you can use something like this:</p>
  
  <pre><code>l = []
  for n in range(1, 11):
      l.append(n)
  </code></pre>
  
  <p>We can shorten this to a list comprehension: <code>l = [n for n in range(1, 11)]</code>.</p>
  
  <p>However, say I want to set a dictionary's keys to the same value.
  I can do:</p>
  
  <pre><code>d = {}
  for n in range(1, 11):
       d[n] = True # same value for each
  </code></pre>
  
  <p>I've tried this:</p>
  
  <pre><code>d = {}
  d[i for i in range(1, 11)] = True
  </code></pre>
  
  <p>However, I get a <code>SyntaxError</code> on the <code>for</code>.</p>
  
  <p>In addition (I don't need this part, but just wondering), can you set a dictionary's keys to a bunch of different values, like this:</p>
  
  <pre><code>d = {}
  for n in range(1, 11):
      d[n] = n
  </code></pre>
  
  <p>Is this possible with a dictionary comprehension?</p>
  
  <pre><code>d = {}
  d[i for i in range(1, 11)] = [x for x in range(1, 11)]
  </code></pre>
  
  <p>This also raises a <code>SyntaxError</code> on the <code>for</code>.</p>