title: Python output out of order
body: <p>I needed some really simple XML output so I decided to write my own functions.  This was just the first step, but something has gone terribly wrong. While I would expect the output to look like this:</p>
  
  <pre><code>&lt;A&gt;
      &lt;D&gt;
          &lt;I&gt;&lt;/I&gt;
          &lt;J&gt;&lt;/J&gt;
          &lt;K&gt;&lt;/K&gt;
      &lt;/D&gt;
      &lt;E&gt;
          &lt;I&gt;&lt;/I&gt;
          &lt;J&gt;&lt;/J&gt;
          &lt;K&gt;&lt;/K&gt;
      &lt;/E&gt;
  </code></pre>
  
  <p>...and so on.</p>
  
  <p>Instead the output looks like this:</p>
  
  <pre><code>  &lt;I&gt;&lt;/I&gt;
    &lt;J&gt;&lt;/J&gt;
    &lt;K&gt;&lt;/K&gt;
   &lt;D&gt;
   &lt;/D&gt;
   &lt;E&gt;
   &lt;/E&gt;
   &lt;F&gt;
   &lt;/F&gt;
   &lt;G&gt;
   &lt;/G&gt;
   &lt;H&gt;
   &lt;/H&gt;
  &lt;A&gt;
  &lt;/A&gt;
  &lt;B&gt;
  &lt;/B&gt;
  &lt;C&gt;
  &lt;/C&gt;
  </code></pre>
  
  <p>I'm sure my mistake is something very simple, but I just can't see it.  This is the entire file that I'm using:</p>
  
  <pre><code>def XMLChild(list, depth):
      for arg in list:
          print '\t' * depth + '&lt;' + arg + '&gt;&lt;/' + arg + '&gt;'
  
  def XMLParent(list, depth, child):
      for arg in list:
          print '\t' * depth + '&lt;' + arg + '&gt;'
          child
          print '\t' * depth + '&lt;/' + arg + '&gt;'
  
  list1 = ['A', 'B', 'C']
  list2 = ['D', 'E', 'F', 'G', 'H']
  list3 = ['I', 'J', 'K', ]
  
  XMLParent(list1, 0, XMLParent(list2, 1, XMLChild(list3, 2)))
  </code></pre>
  
  <p>As you can see, both functions are supposed to print tags.  XMLParent should allow the passing of a child function, either another parent or a child.  No matter how much I look at it I can't figure out why it's printing the way it is.</p>