469,964 Members | 1,474 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

doing successive prints without space in between

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?
Jul 18 '05 #1
3 1493
Jon Perez wrote:
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

--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
Jul 18 '05 #2
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

Jul 18 '05 #3
Jon Perez <jb********@yahoo.com> writes:
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')

--
ha************@boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Marcin Ciura | last post: by
2 posts views Thread by André Hänsel | last post: by
7 posts views Thread by Prashanth Badabagni | last post: by
1 post views Thread by Digital Puer | last post: by
3 posts views Thread by Franco Perilli | last post: by
15 posts views Thread by robert maas, see http://tinyurl.com/uh3t | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.