doing successive prints without space in between

J

Jon Perez

I'd like to print a series of successive periods as a
progress status in a command line script using python.
Unforutnately, if I do a series of successive

print ".",

I get a space in between. Is there any way to avoid
this?
 
B

Brian van den Broek

Jon Perez said unto the world upon 02/07/2004 16:00:
I'd like to print a series of successive periods as a
progress status in a command line script using python.
Unforutnately, if I do a series of successive

print ".",

I get a space in between. Is there any way to avoid
this?

Hi,

mid-June there was a thread "Printing a progress bar" on the Tutor list
that might be of interest to you.

Best,

Brian vdB
 
D

Dave Kuhlman

Jon said:
I'd like to print a series of successive periods as a
progress status in a command line script using python.
Unforutnately, if I do a series of successive

print ".",

I get a space in between. Is there any way to avoid
this?

import sys

sys.stdout.write('.')

The print command sends its output to sys.stdout (which you can
customize, by the way, by replacing sys.stdout with an instance of
a class containing a 'write' method; see
http://docs.python.org/lib/module-sys.html)

Dave
 
H

Harry George

Jon Perez said:
I'd like to print a series of successive periods as a
progress status in a command line script using python.
Unforutnately, if I do a series of successive

print ".",

I get a space in between. Is there any way to avoid
this?

This show up regularly and might be a FAQ. The print is trying to
help you out. If you want total control, go to the lower levels:

wr=sys.stdout #redirect as desired

def myprint(txt):
wr.write(txt) #raw print
wr.flush() #flush the dots as they occur

for i in range(100):
do_something()
myprint('.')

myprint('\n')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top