468,287 Members | 1,977 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,287 developers. It's quick & easy.

Printing dots in sequence ('...')

This is a very newbie question for my first post, perhaps
appropriately.

I want to print '....' gradually, as a progress indicator. I have a
for-loop that every 10 steps executes:
print '.',

This results in something like 'Loading. . . .', whereas I want
'Loading....'

A pet peeve, I can't for the life of me figure out how to get this
desired output. How do I print dots - or anything for that matter - in
sequence without a space being inserted in between?

Thanks.
Björn

May 22 '07 #1
4 10496
beertje wrote:
This is a very newbie question for my first post, perhaps
appropriately.

I want to print '....' gradually, as a progress indicator. I have a
for-loop that every 10 steps executes:
print '.',

This results in something like 'Loading. . . .', whereas I want
'Loading....'

A pet peeve, I can't for the life of me figure out how to get this
desired output.
I love understatement.
How do I print dots - or anything for that matter - in
sequence without a space being inserted in between?
>>import sys, time
for i in range(10):
.... sys.stdout.write(".")
.... sys.stdout.flush()
.... time.sleep(.1)
....
...........>>>

write() does the writing, flush() is to defeat the buffering; without it the
dots would be withhold until the next newline. The time.sleep() call is
that you can see it is actually one dot at a time.

Peter
May 22 '07 #2
Perfect, thanks :)

May 22 '07 #3
beertje wrote:
This is a very newbie question for my first post, perhaps
appropriately.

I want to print '....' gradually, as a progress indicator. I have a
for-loop that every 10 steps executes:
print '.',

This results in something like 'Loading. . . .', whereas I want
'Loading....'

A pet peeve, I can't for the life of me figure out how to get this
desired output. How do I print dots - or anything for that matter - in
sequence without a space being inserted in between?

Thanks.
Björn
I wrote this a donated to Python Cookbook some time ago, enjoy.

http://aspn.activestate.com/ASPN/Coo.../Recipe/299207

-Larry
May 22 '07 #4
beertje wrote:
This is a very newbie question for my first post, perhaps
appropriately.

I want to print '....' gradually, as a progress indicator. I have a
for-loop that every 10 steps executes:
print '.',

This results in something like 'Loading. . . .', whereas I want
'Loading....'

A pet peeve, I can't for the life of me figure out how to get this
desired output. How do I print dots - or anything for that matter - in
sequence without a space being inserted in between?

Thanks.
Björn
See example here:

http://aspn.activestate.com/ASPN/Coo.../Recipe/299207

-Larry
May 22 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by | last post: by
reply views Thread by Chris | last post: by
2 posts views Thread by qumpus | last post: by
7 posts views Thread by DazedAndConfused | last post: by
10 posts views Thread by sophie_newbie | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.