title: What is the best way to parse this YAML template in Python?
body: <p>We're switching from an old app with a specific task that is no longer being maintained, and developing a custom solution.</p>
  <p>Essentially, I need to iterate through these pairs of URLs and tokens.  They're in sets of 2, meaning that each:</p>
  <pre><code>  - url: http://192.168.0.8:PORT
    token: XXXXXXXXXXXXXXXXXXXX
  </code></pre>
  <p>pair is the authentication for one instance of a different application it needs to access.</p>
  <p>The end goal is to loop through each pair, in a for loop, and run a specific command per pair.</p>
  <p>I've tried getting this to give in with <a href="https://confuse.readthedocs.io/en/latest/" rel="nofollow noreferrer">Confuse</a> and also <a href="https://pyyaml.org/" rel="nofollow noreferrer">PyYAML</a> and so far, its been smashing my head in.</p>
  <p>Full Template:</p>
  <pre><code>targets:
    application:
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
   
      - url: http://192.168.0.8:PORT
        token: XXXXXXXXXXXXXXXXXXXX
  </code></pre>