title: Python carriage return
body: <p>I am using Python 2.7.13(in Kali 4.9.0 amd64), and I have tried every variation of the print() statement that I can find(with the proper <strong>future</strong> import statements), and I am ending up with OK on a newline everytime. Here is the code:</p>
  
  <pre><code>from __future__ import print_function
  
  for i in range(0, 10000):
  print("\rOK", end="")
  </code></pre>
  
  <p>I have tried:</p>
  
  <ul>
  <li><p>single quotes instead of double for end=""</p></li>
  <li><p>using Python 2.x syntax instead of importing print_function and using 3.0 syntax</p></li>
  <li><p>end='\r' end="\r"</p></li>
  <li><p>a space in between the quotes of end=""</p></li>
  </ul>
  
  <p>When I used the 2.7 syntax, I was able to get the output to stay on the same line but still printing in a row, when I try to use a carriage return to return the cursor to the beginning position(and overwrite previous output), it inserts a newline, even with a terminating comma in my print statement. 
  I have read Question <a href="https://stackoverflow.com/questions/3249524/print-in-one-line-dynamically">3249524</a>, along with well over a dozen other explanations for this problem.  I have also tried using the sys.stdout functions instead:</p>
  
  <pre><code>import sys
  
  for i in range(10):
  sys.stdout.write("\rCountdown: %d" % i)
  sys.stdout.flush()
  </code></pre>
  
  <p>The output of both programs is still on a newline every time. I am at a loss as to how to get it to print in the same place on the same line. Thanks to anyone who can illuminate this issue.</p>