Re: [Tutor] Printing the Carriage return character
Thanks Alan for clearing that up...I was trying to see why my "\r\n" does not print 2 empty lines when I stumbled across this 'gotcha'. -Original Message- From: Alan Gauld [mailto:[EMAIL PROTECTED] Sent: Monday, 20 February 2006 9:22 p.m. To: Hans Dushanthakumar; tutor@python.org Subject: Re: [Tutor] Printing the Carriage return character >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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Printing the Carriage return character
>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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Printing the Carriage return character
Hi, Not sure if this is a python thing or a Operating system peculiarity, but here goes: 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)? Output in IDLE (ver 1.1.1, python 2.4.1): >>> print "FirstLine" + "\rSecondLine" FirstLine SecondLine >>> Output at the python prompt (python 2.4.1): C:\QVCS\Mobile Data\>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print "FirstLine" + "\rSecondLine" SecondLine >>> Cheers Hans ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor