print without newline

Janko Hauser jhauser at ifm.uni-kiel.de
Fri Jun 9 10:15:37 EDT 2000


The print statement prints to stdout. You can get a handle of the
stdout file object and use it's write method.

>> import sys
>>> sys.stdout.write('test')
test>>> 

HTH,
__Janko

Eckhard Pfluegel <Eckhard at pfluegel.fsnet.co.uk> writes:

> I want to print a string without a newline afterwards. The command
> 
> print "foo",
> 
> doesn't print a newline but prints a trailing space, which is not what I
> want (I wnat *nothing* after the string). I tried the formated output
> 
> print "%s" % ("foo")
> 
> but this prints a newline as well.
> 
> I use Python 1.5.2 on Linux.
> 
> Does anybody have an idea? Thanks very much in advance.
> 
> Eckhard
> 
> 
> 
> 

-- 
  Institut fuer Meereskunde             phone: 49-431-597 3989
  Dept. Theoretical Oceanography        fax  : 49-431-565876
  Duesternbrooker Weg 20                email: jhauser at ifm.uni-kiel.de
  24105 Kiel, Germany



More information about the Python-list mailing list