print, sys.stdout & % complete HELP
bragib at my-deja.com
bragib at my-deja.com
Wed May 24 16:30:01 EDT 2000
More information about the Python-list mailing list
Wed May 24 16:30:01 EDT 2000
- Previous message (by thread): print, sys.stdout & % complete HELP
- Next message (by thread): How do I create extensions to Python in C?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks Greg... Works like a charm.... :) Bragi p.s. Andy please share the warn stuff with us if you write it up. In article <392BE18F.D5F21F27 at earthlink.net>, greg Landrum <greglandrum at earthlink.net> wrote: > bragib at my-deja.com wrote: > > > > Hi: > > > > I am trying to print a status message to a terminal window which tells > > the user percent complete. > > > > This is the way I went about it in pseudo terms > > > > def percentComplete(lineNo, lines, fileName): > > msg = 'Scanning file %s, %i%s complete.' > > percentComplete = int(round(100*lineNo/lines)) > > if divmod(percentComplete, 5)[1]: # every 5% > > backspace = '\b'*len(oldStatus) > > msg = backspace + msg %(fileName, percentComplete, '%') > > print msg, > > oldStatus = msg > > > > Now I have the problem as follows: > > prompt>Scanning file longLongLongName.fil, 100% complete. > > > > Then when I start scanning a file witha shorter name I > > get > > prompt>Scanning file short.fil, 20% complete. ete. <--- Oops something > > did not get erased. > > I could not get things to work properly with print (I assume this is due > to buffering problems) under kdeterm, but the following works just fine > for me: > > for i in xrange(100): > sys.stdout.write('\rDoing %d'%i) > sys.stdout.flush() > time.sleep(.1) > > -greg > > -- > > greg Landrum (greglandrum at earthlink.net) > Software Carpenter/Computational Chemist > Sent via Deja.com http://www.deja.com/ Before you buy.
- Previous message (by thread): print, sys.stdout & % complete HELP
- Next message (by thread): How do I create extensions to Python in C?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list