[Tutor] carriage return on windows

Kent Johnson kent37 at tds.net
Sun Jan 30 04:11:54 CET 2005


It seems to work fine in Win2k command shell; try this:

  >>> import time
  >>> time.sleep(1)
  >>> for i in range(9):
  ...   print 'i is', i, '\r',
  ...   time.sleep(1)

I get all the output on one line.

Kent

Jacob S. wrote:
> I don't think that's what he wants. I think he wants to *overwrite* 
> what's in the shell with new output.
> For example.
> 
> Python 2.4 (#Stuff)
> ...
> 
>>>>
> Percent complete: 50
> 
> 
> becomes...
> 
> Python2.4(#Stuff)
> ...
> 
>>>>
> Percent complete: 51
> 
> so that the whole line is overwritten. In my experience, this is not 
> possible and if anyone can show me how to do it,
> I would be grateful.
> 
> HTH,
> Jacob
> 
> 
>>
>> On Jan 30, 2005, at 02:18, R. Alan Monroe wrote:
>>
>>>
>>>> print "Percent completed:" + str(percent) + "\r"
>>>
>>>
>>> Print forces a newline.
>>> Try sys.stdout.write instead.
>>>
>>> Alan
>>
>>
>> You can also use the following syntax:
>>
>> >>> print "Percent completed:", str(percent), "\r",
>>
>> The trailing comma is NOT a typo, it is intentional. It prevents print 
>> from appending a newline.
>>
>> -- Max
>> maxnoel_fr at yahoo dot fr -- ICQ #85274019
>> "Look at you hacker... A pathetic creature of meat and bone, panting 
>> and sweating as you run through my corridors... How can you challenge 
>> a perfect, immortal machine?"
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



More information about the Tutor mailing list