[Tutor] Displaying Status on the Command Line

Alan Gauld alan.gauld at yahoo.co.uk
Thu Nov 8 05:42:44 EST 2018


On 08/11/2018 04:06, Chip Wachob wrote:

> I should have mentioned that I'm working with Python 2, but I think I
> can parse my way through these examples.

OK, In that case you may want to investigate the sys.stdout approach.
Just remember it's a pre opened file and use the write() method.
But it won't do any of the print type things, you need to
convert all values to strings and add in new lines etc yourself.

IN fact if you go that way you might want to use sys.stderr
instead since that will mean your progress indicator does not
appear in the true output should you pipe it into a file.

And finally, don't forget the >>> prompt is your friend
for this kind of thing. Experiment there to get it right
before committing it to a larger script.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list