Pywin print w/o linefeed?

Erik Max Francis max at alcyone.com
Tue Jan 21 15:38:10 EST 2003


Spencer Ernest Doidge wrote:

> Is there some way to make Python print a string without the linefeed
> at the end? If there were <some instruction> to do that, then I could
> do this:
>
> >>> def go():
>         <some instruction> 'hello world'
>         <some instruction> 'goodbye world'
> 
> >>> go()
> hello worldgoodbye world

You can put a trailing comma after the print statement, but that will
include a space as well, depending on whether or not softspace is set,
etc.

For fine control over the exact details of what is printed, use
sys.stdout.write directly.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ He who conceals his disease cannot expect to be cured.
\__/ (an Ethiopian proverb)
    Maths reference / http://www.alcyone.com/max/reference/maths/
 A mathematics reference.




More information about the Python-list mailing list