title: Accessing List of Dictionary Items
body: <p>I have the following code to create a list of dictionaries of images:</p>
  
  <pre><code>planet_templates = []
  for file in glob.glob("templates/*.png"):
      image = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
      width, height = image.shape
      imdict = {
          'name': file,
          'height': height,
          'width': width,
      }
      planet_templates.append(imdict)
  </code></pre>
  
  <p>which bascially reads the images under a folder and puts them into list of dictionaries. </p>
  
  <p>I'd like to read then each of their dictionary values and keys into variables in a loop properly. So I am trying the following:</p>
  
  <pre><code>for dict in planet_templates:
      for key in dict:
          print(dict[key])
  </code></pre>
  
  <p>However this does not give me what I want. Instead, throws the whole list without any name, width or height tagged:</p>
  
  <pre><code>222
  templates/jupiter.png
  294
  713
  templates/sun.png
  137
  161
  templates/uranus.png
  139
  44
  templates/mercury.png
  44
  50
  templates/mars.png
  50
  200
  templates/saturn.png
  217
  49
  templates/venus.png
  43
  58
  templates/earth.png
  55
  107
  templates/neptune.png
  148
  </code></pre>
  
  <p>whereas I'd like to have:</p>
  
  <pre><code>name: templates/neptune.png
  height: 148
  width: 107
  </code></pre>
  
  <p>and even assign them to variables, if possible. Such as:</p>
  
  <pre><code>width, height, name = templates[i].shape[::-1]
  </code></pre>
  
  <p>Of course <code>shape[::-1]</code> here won't work because dictionary has no such attribute, but you get the point, something equivalent.</p>
  
  <p>How can I achieve this? Thanks in advance.</p>