2

I searched and couldn't find an answer to this. I'm trying to use '\r' as a carriage return in a program but it behaves like a newline instead. Here's the code I'm trying to use, adapted for Python 3 from "Learn Python the Hard Way"

while True:
    for i in ["/","-","|","\\","|"]:
        print("%s\r" % i, end='')

It's supposed to look like a little rotating bar, like a busy animation or something, but it prints each new character to a newline. How do I get the carriage return to behave like an actual carriage return?

Paul Richter
  • 10,908
  • 10
  • 52
  • 85
nonex
  • 233
  • 3
  • 12
  • maybe you should print with a "," (comma character)? check out http://stackoverflow.com/a/3419991/583834 – arturomp Jan 15 '14 at 17:13
  • How are you invoking this program? Are you running in an IDE? – Robᵩ Jan 15 '14 at 17:14
  • I'm running in IDLE. I feel kind of silly now because I just ran it from the command line and it worked as expected. @amp, that method only works in Python <3. – nonex Jan 15 '14 at 22:07

0 Answers0