pythonpython-idle

Carriage return (\r) works different on python idle vs VS Code


import time

for i in range(10):
    print(f"Progress: {i}/10", end='\r')
    time.sleep(1)

When I run this code in VS Code it works as expected by showing "Progress" in place going from 1 to 10, but when running it on the idle it displays the following:

Progress: 0/10Progress: 1/10Progress: 2/10Progress: 3/10Progress: 4/10Progress: 5/10Progress: 6/10Progress: 7/10Progress: 8/10Progress: 9/10

What's the reason for this?

I tried some online idle sites like W3Schools and they output the same thing like the picture.


Solution

  • It seems that IDLE still doesn't support most control characters such as \r etc (I ran this on Python IDLE 3.12.2 ) link to the original psot Carriage Return not working in IDLE?