title: Loop through all nested dictionary values?
body: <pre><code>for k, v in d.iteritems():
      if type(v) is dict:
          for t, c in v.iteritems():
              print "{0} : {1}".format(t, c)
  </code></pre>
  
  <p>I'm trying to loop through a dictionary and print out all key value pairs where the value is not a nested dictionary. If the value is a dictionary I want to go into it and print out its key value pairs...etc. Any help?</p>
  
  <p>EDIT</p>
  
  <p>How about this? It still only prints one thing.</p>
  
  <pre><code>def printDict(d):
      for k, v in d.iteritems():
          if type(v) is dict:
              printDict(v)
          else:
              print "{0} : {1}".format(k, v)
  </code></pre>
  
  <p>Full Test Case</p>
  
  <p>Dictionary:</p>
  
  <pre><code>{u'xml': {u'config': {u'portstatus': {u'status': u'good'}, u'target': u'1'},
        u'port': u'11'}}
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>xml : {u'config': {u'portstatus': {u'status': u'good'}, u'target': u'1'}, u'port': u'11'}
  </code></pre>