print there!

Steven D'Aprano steve at REMOVETHIScyber.com.au
Tue Sep 20 19:10:24 EDT 2005


On Tue, 20 Sep 2005 14:06:23 +0200, Fredrik Lundh wrote:

> Godwin Burby wrote:
> 
>> print 'c:\godwin\bl.csv',
>> for i,row in enumerate(reader):
>>    # inserts or updates the database
>>    print i,
>> This displays on the screen as :
>> c:\godwin\bl.csv 1 2 3 4 5 6 7 8
>>                 ^
>> But i want it to show the above numbers on the same spot denoted by the
>> carat character. Can it be done with print statement or any other trick?
> 
> carriage return is your friend:
> 
>     filename = 'c:\\godwin\\bl.csv',
>     for i,row in enumerate(reader):
>         # inserts or updates the database
>         print "\r" + filename, i,
>     print

That may not be enough. You may need to flush the print buffer using
sys.stout.flush().


-- 
Steven.





More information about the Python-list mailing list