printing dots in simple program while waiting
Tim Chase
python.list at tim.thechases.com
Wed Jan 9 12:06:01 EST 2008
Martin Marcher wrote:
> John wrote:
>
>> import time
>> s = '.'
>> print 'working', # Note the "," at the end of the line
>> while True:
>> print s, #Note the "," at the end of this line too...
>> time.sleep(1)
>
> see my comment in the code above...
see my added comment in the code above...
Though this will produce spaces between the dots:
waiting . . . . . .
To eliminate the spaces, you need to write to a file-stream such
as sys.stdout:
from sys import stdout
stdout.write('working')
while True:
stdout.write('.')
# might need something like stdout.flush() here
time.sleep(1)
stdout.write('\n')
-tkc
More information about the Python-list
mailing list