[Tutor] Blank line added after reading a line from a file

Andrei Kulakov ak@silmarill.org
Thu, 06 Dec 2001 00:40:47 -0500


On Wed, Dec 05, 2001 at 10:58:58AM -0800, Danny Yoo wrote:
> On Wed, 5 Dec 2001, Andrei Kulakov wrote:
> > a list of lines, without adding "\n", and yet another solution is to add
> > a comma after the print statement, which prevents it from printing a
> > newline, like this:
> > 
> > print line,
> 
> 
> Putting in the comma suppresses print from adding a newline of its own,
> but doesn't stop printing newlines if the line itself contains them:

Yes, but the dude's problem was that it'd print *two* new lines. He just
wanted one. That's where comma would help :P.

> 
> ###
> >>> def test():
> ...     print "hello\n"
> ...     print "hello again\n",
> ...     print "one more time"
> ... 
> >>> test()
> hello
> 
> hello again
> one more time
> ###
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org