title: Python 3: Is there an elegant way to turn a string into a 2 dimensional dict using dictionary comprehension?
body: <p>Is there a more elegant way to achieve the same result using dictionary comprehension?</p>
  
  <p>For clarification the format of <code>s</code> will always be <code>"foo 1=bar 2=bar"</code></p>
  
  <pre><code>s = "foo 1=bar 2=bar"
  x = s.split()
  
  for i in x:
  
      if '=' not in i:
          d = {
              i:{
                  x[1].split('=')[0]: x[1].split('=')[1],
                  x[2].split('=')[0]: x[1].split('=')[1]
              }
          }
  
  d
  Out[27]: {'foo': {'1': 'bar', '2': 'bar'}} 
  </code></pre>