I want to have various terminal printouts while also having a progress bar displayed at the same place on the terminal (say, the bottom) and I want this to work in Python 2 and 3. The code I have now is as follows:
#!/usr/bin/env python
import sys
import time
maximumValue = 10
for i in range(0, maximumValue):
#print("my count number: {count}".format(count = i))
sys.stdout.write("\r[" + i * "=" + ">" + (maximumValue - i - 1) * " " + "]")
sys.stdout.flush()
time.sleep(0.5)
sys.stdout.write("\n")
The progress bar prints out reasonably here, but when I include the print statement, the progress bar gets printed such that it appears multiple times in the terminal. How can I get a single progress bar to appear while also printing terminal outputs?