Using Python 3.4, is there a platform-agnostic method of printing between the last and second-to-last lines? What I'm trying to accomplish is basically a progress bar always on the last line. The 2nd line and up are just debug logs. For example:
[DEBUG] Some info...
[DEBUG] More info...
Download Progress: [#### ] 40% (3 of 20)
I run some downloads in a loop. Each iteration of the loop I run this to print the progress bar:
def _print_progress_bar(self):
amt_done = self._count / self._max
print('\rDownload Progress: [{:20s}] {:.1f}% ({})'.format(
'#' * int(amt_done * 20),
amt_done * 100,
self._padded_counter(' of ')), end='')
Between calls to this method to render the progress bar, I want to insert diagnostic messages above it (I do not want print
statements after this to overwrite the progress bar, basically).
How can I do this?