how do i keep python from printing a newline when it exits the program?

Peter Otten __peter__ at web.de
Mon Oct 11 11:35:19 EDT 2004


xegfault wrote:

> print "No newline, please.",
> # End of script
> 
> When the program runs, python is still printing a newline when the
> program exits.  How does one keep python from doing so?

Use sys.stdout.write() instead of print or clear the softspace flag

sys.stdout.softspace = False

after the print statement. Google 'site:mail.python.org exit newline' for
some background.

Peter




More information about the Python-list mailing list