doing successive prints without space in between

Harry George harry.g.george at boeing.com
Fri Jul 2 16:59:39 EDT 2004


Jon Perez <jbperez808 at 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')

-- 
harry.g.george at boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007



More information about the Python-list mailing list