Problems with sys.stout.flush()
Peter Otten
__peter__ at web.de
Sat May 23 11:12:10 EDT 2009
Joel Ross wrote:
> class progress:
>
> def progressbar(self, number, total, char):
>
> percentage = float(number*100)/total
> percentage = int(round(percentage))
> percentage = int(100 - percentage)
> self.f=sys.stdout
> if percentage > 0:
> char = char * percentage
Carl probably overlooked that you didn't follow his advice. If you want to
overwrite the current line you have to send a "\r" to the terminal. Change
> self.f.write(char)
to
self.f.write("\r" + char)
> self.f.flush()
> sleep(0.2)
More information about the Python-list
mailing list