How to print 'tight' dots horizontally in python?
If you want to get more control over the formatting then you need to use either:
import sys
sys.stdout.write('.')
sys.stdout.flush() # otherwise won't show until some newline printed
.. instead of print
, or use the Python 3 print function. This is available as a future import in later builds of Python 2.x as:
from __future__ import print_function
print('.', end='')
In Python 3 you can pass the keyword argument flush
:
print('.', end='', flush=True)
which has the same effect as the two lines of sys.stdout
above.