ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: Printing repeatedly on same line
by Jason Morgan other posts by this author
Jan 25 2003 4:35PM messages near this date
Re: Printing repeatedly on same line | Re: repr of type and class objects
Thanks, that was too easy.

Jason


On Sat, Jan 25, 2003 at 11:28:27AM -0500, Markus Wankus wrote:
>  Using sys.stdout.write() will work if you do not add your own '\n' to the 
>  end of it.
>  
>  Otherwise, add a *comma* to th eprint statement, liek so:
>  
>  print "Crap",
>  
>  Markus.
>  
>  On Sat, 25 Jan 2003 16:18:50 -0000, Andrew Wilkinson 
>  <ajw126NO@[...].uk> wrote:
>  
>  >Jason Morgan wrote:
>  >>How do I print (stdout) to the same line repeatedly? I want to offer a
>  >>status bar for a script. I have tried the following:
>  >>
>  >>def statprint(s):  # s is a string
>  >>import sys
>  >>sys.stdout.write(s+" "*(78-len(s))+"\r")
>  >>
>  >>I got this from this ASPN page:
>  >>
>  >>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146038
>  >>
>  >>which seemed to be refering to Windows (I'm writing for Linux/*BSD). I
>  >>have tried the above function, but it prints in the same manner as
>  >>'print' does.
>  >>
>  >>
>  >>Thanks for the help in advance.
>  >>
>  >>Cheers,
>  >>Jason
>  >
>  >Try just adding a semicolon at the end of the print statement.
>  >For example
>  >
>  >print 1,
>  >print 2
>  >
>  >will give you
>  >1 2
>  >
>  >HTH,
>  >Andrew Wilkinson
>  -- 
>  http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list
Thread:
Andrew Wilkinson
Markus Wankus
Jason Morgan

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved