printing dots in simple program while waiting

John john.m.roach at gmail.com
Wed Jan 9 20:30:45 CET 2008


On Jan 9, 12:14 pm, "Reedick, Andrew" <jr9... at ATT.COM> wrote:
> > -----Original Message-----
> > From: python-list-bounces+jr9445=att.... at python.org [mailto:python-
> > list-bounces+jr9445=att.... at python.org] On Behalf Of Martin Marcher
> > Sent: Wednesday, January 09, 2008 11:57 AM
> > To: python-l... at python.org
> > Subject: Re: printing dots in simple program while waiting
>
> > John wrote:
>
> > > import time
> > > s = '.'
> > > print 'working', # Note the "," at the end of the line
> > > while True:
> > >     print s
> > >     time.sleep(1)
>
> > see my comment in the code above...
>
> > if that's what you mean
>
> Bah.  The trailing command may prevent the newline, but it appends a
> space whether you want it or not.[1]  Use sys.stdout.write('.') instead.
>
> import sys
>
> print "wussy nanny state, tax 'n spend my spaces, liberal comma:"
> for i in range(1, 10):
>         print '.',
> print
> print "manly neo-con I know what's Right so keep your government out of
> my strings! print:"
> for i in range(1, 10):
>         sys.stdout.write('.')
>
> [1] Which has to be _the_ most annoying feature of Python.  *grrr*
>
> *****
>
> The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA625





Thanks for all of the help.  This is what ended up working:



import time
import sys

s = '.'
sys.stdout.write( 'working' )
while True:
        sys.stdout.write( s )
        sys.stdout.flush()
        time.sleep(0.5)






More information about the Python-list mailing list