title: Python string formatting: For loops?
body: <p>I really enjoy the Django/Jinja style of formatting. I understand wanting to keep logic and presentation separate, but the if statements and for loops are ideal when reporting a changing amount of data.</p>
  
  <p>I am creating a "Report" class that returns some information about the inputs and outputs of a function in a more verbose way, and what I would like is to have a string like:</p>
  
  <pre><code>template="""
  INPUTS:
  {{% for key,value in inputsdict.items() %}}
    {{key}}: {{value}}
  {{% endfor #}}
  
  OUTPUTS:
  {{% for key,value in outputsdict.items() %}}
    {{key}}: {{value}}
  {{% endfor #}}
  """
  </code></pre>
  
  <p>and then I could just call a classic <code>template.format(**kwargs)</code></p>
  
  <p>I am wondering if Jinja is my best bet to do this, or whether python has a native, lightweight string loop formatting functionality of some kind that I should be looking at.</p>
  
  <p>Edit: Additionally, if Jinja is my best bet, I would really appreciate an example of how to use it outside of a web-oriented environment. The docs are kind of hard to navigate.</p>