A simple way to print few line stuck to the same position
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Jun 2 10:16:38 EDT 2011
On Thu, 02 Jun 2011 21:22:40 +0800, TheSaint wrote:
> Hello
> I studying some way to print few line in the console that won't scroll
> down. If was for a single line I've some idea, but several line it may
> take some vertical tab and find the original first position. I don't
> know anything about course module, some example will be highly
> apreciated.
I think you want something like this:
import sys
import time
def spinner():
chars = '|/-\\'
for i in range(30):
for c in chars:
sys.stdout.write(' %3d :: %s\r' % (i, c))
sys.stdout.flush()
time.sleep(0.2)
--
Steven
More information about the Python-list
mailing list