how to suppress carriage return/line feed?

Erik Max Francis max at
Wed Oct 30 23:01:57 CET 2002

TuxTrax wrote:

> Erik, if you would, I would like to see an example of
> sys.stdout.write()
> and flush() in action, with a sample codelet. Thanks,

	import sys, time

	for i in range(10):
	    sys.stdout.write("Counting %s\r")

As I pointed out earlier, this still isn't a perfect solution; you're
not guaranteed that some terminals won't interpret '\r' (CR)
differently.  For instance, on a Mac, this would likely print each one
on a separate line.  On Windows and UNIX, it will likely work, but again
you could conceivably be using some terminal that does something

If you really want total positioning control, you'll have to go with
some solution like curses (but that isn't available for Windows).

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ It's a man's world, and you men can have it.
\__/ Katherine Anne Porter
    Rules for Buh /
 The official rules to the betting card game, Buh.

More information about the Python-list mailing list