[Tutor] Blank line added after reading a line from a file
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 again
> one more time
> Tutor maillist - Tutor@python.org
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org