Pywin print w/o linefeed?

John Roth johnroth at ameritech.net
Tue Jan 21 15:20:41 EST 2003


"Spencer Ernest Doidge" <spencer at efn.org> wrote in message
news:b0k9e9$f5q$1 at news.efn.org...
> Running Pythonwin, you get:
>
> >>> def go():
>         print 'hello world'
>         print 'goodbye world'
>
> >>> go()
> hello world
> goodbye world
>
> 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
>
> I know that I could accumulate a string and then make one print
statement,
> but is there some other way? For those who remember Pascal, WRITELN
corresponds
> to Python's print. Is there a Python way to implement the equivalent
of Pascal'sWRITE?

import sys
sys.stdout.write("hello world")
sys.stdout.write("goodby world\n")

The print statement is intended for human readable output such as
debugging
lines, hence the newline that's automatically inserted at the end.

John Roth
>
>
>
> --
> Spencer Doidge






More information about the Python-list mailing list