title: Print to a specific line on stdout using Python
body: <p>I would like to print to a specific line on stdout using Python.</p>
  
  <p>Say.. I have a loop within a loop. Currently it prints this :</p>
  
  <pre><code>a0,b0,c0,a1,b1,c1,a2,b2,c2,
  </code></pre>
  
  <p>But actually I want it to print this :</p>
  
  <pre><code>a0,a1,a2,
  b0,b1,b2,
  c0,c1,c2,
  </code></pre>
  
  <p>the code looks something like this</p>
  
  <p>import sys</p>
  
  <pre><code>ar = ['a', 'b', 'c']
  for i in ar:
      c = 1
      while c &lt; 4:
          sys.stdout.write('%s%s,' % (i, c))
          c += 1
  </code></pre>
  
  <p>Is there a way of identify the line ? eg print to line X ?</p>
  
  <p>Or - can I write 3 lines to stdout (using '\n'), then go back and overwrite line 1 ?</p>
  
  <p><em>note: I don't just want to achieve the above ! I can do that by altering the loop - the question is about identifying different lines of stdout and writing to them, if possible</em></p>
  
  <p>Thanks</p>