[Tutor] Printing the Carriage return character
Alan Gauld
alan.gauld at freenet.co.uk
Mon Feb 20 09:22:01 CET 2006
> Not sure if this is a python thing or a Operating system peculiarity,
An IDLE thing specifically - or maybe even a Tkinter thing...
> Why does the line
> print "FirstLine" + "\rSecondLine"
> produce different output when run via IDLE and when run in the python
> prompt (both under Windows XP)?
\r is a carriage return which literally means that the printhead carriage
should return to the start of the line. You need a line feed character if
you want a new line too.
Unfortunately some OS use \r to do both, others need both.
The safe way is to use \n (new line) instead.
> Output in IDLE (ver 1.1.1, python 2.4.1):
> FirstLine
> SecondLine
> Output at the python prompt (python 2.4.1):
> SecondLine
So being pedantic XP is correct, IDLE is wrong but in fact
because the conventions are so mixed up right and wrong is
a bit woolly.
Which response were you trying to get?
Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list