On the spot counter - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: On the spot counter (/thread-22795.html) Pages:
1
2
|
On the spot counter - Astrikor - Nov-27-2019 I would like to display a count in the Console such that each increment is replaced in the same place (at start of line) by the next. Having looked at posts on overwriting the last line, I thought this should work ok, but it adds each increment to the last line instead of replacing it import time for i in range (15): time.sleep(1) print(i, end="\r")result is: 1234567891011121314 note also that when it gets to 6 there is a long gap to 7: 123456 7 What am I doing wrong? Many thanks Astrikor RE: On the spot counter - ThomasL - Nov-27-2019 What OS are you using? In my Win10 console everything works as intended. RE: On the spot counter - Larz60+ - Nov-27-2019 use: >>> import time >>> for i in range(15): ... time.sleep(1) ... print(f"{i} ", end='\r') ... >>> RE: On the spot counter - Astrikor - Nov-27-2019 ThomasL: I'm using Win7 with Python 3.7.4 Larz60+: Thanks, but that gives same result i.e a horizontal row of concatenated i values as in my query. RE: On the spot counter - snippsat - Nov-27-2019 When you say console i guess you mean IDLE? IDLE does not support backspace,carriage-return,form-feed or ANSI escape sequences. If you run from command line(cmd) it will work,or eg cmder as i use. [Image: riru29.png] IDLE is not so good,and is usually only used bye new users for while. RE: On the spot counter - Ray - Nov-27-2019 I also do _not_ see any different pause after 6. I am using spyder from Anaconda Navigator run on Win7. RE: On the spot counter - ThomasL - Nov-28-2019 That´s a problem with Spyder console. Don´t restrict yourself just to this IDE, try different ones. RE: On the spot counter - Astrikor - Nov-28-2019 (Nov-27-2019, 09:54 PM)snippsat Wrote: When you say console i guess you mean IDLE? Thanks snippsat - yes, I am using IDLE - so that's the answer then. I'll try something else - how about Pycharm-community-2019.2.5 ? Thanks again. RE: On the spot counter - Astrikor - Nov-28-2019 [/quote] how about Pycharm-community-2019.2.5 ? [/quote] Oh no! Pycharm doesn't do the job either - it shows blank until it hits the last count value. cmd does work, but is clunky to run a file. I would rather run from an IDE. Any other ideas? RE: On the spot counter - Malt - Nov-28-2019 (Nov-28-2019, 09:54 AM)Astrikor Wrote:(Nov-27-2019, 09:54 PM)snippsat Wrote: When you say console i guess you mean IDLE? I tried in Pycharm, we are getting result but not immediate atleast half a second it is taking |