How do I force Python\'s print function to output to the screen?
This is not a duplicate of Disable output buffering - the linked question is attempting unbuffe
I first struggled to understand how the flush option was working. I wanted to do a 'loading display' and here is the solution I found:
for i in range(100000):
print('{:s}\r'.format(''), end='', flush=True)
print('Loading index: {:d}/100000'.format(i+1), end='')
The first line flushes the previous print and the second line prints a new updated message. I don't know if an one-line syntax exists here.