2

Similar questions have been answered for example here or here.

Building upon the answers provided I am trying to overwrite the last output line in a Spyder console using

interval = 1
for i in range(0,10):
    print(i, end = "\r")
    time.sleep(interval)

which gives me the following, unexpected output:

0123456789

If i reduce the sleep interval to something short interval = 0.01, then I get the output I would expect

9

How can the timing of these consecutive print statements influence what is being printed? And more importantly how do I get my pretty output? This happens only when I use Spyder (3.2.6) and does not occur in a regular Python console.

Herr von Wurst
  • 2,571
  • 5
  • 32
  • 53
  • It could just be the terminal implementation of Spyder. Where they haven't properly implemented the \r character. You say it does not happen in a regular terminal/console? – Wouter Coebergh Jun 28 '18 at 09:28

1 Answers1

2

As far as I know spyderimplements an IPython console, which might behave diferently. Maybe check out this post.

Diana
  • 377
  • 2
  • 8