By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,985 Members | 1,574 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,985 IT Pros & Developers. It's quick & easy.

Printing dots in sequence ('...')

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
Perfect, thanks :)

May 22 '07 #3

P: n/a
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

P: n/a
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.