Thread: \ in idle?
View Single Post
Old Mar 20th, 2007, 12:46 PM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Yes, Python, like almost all other languages, reserves the "\" character for identifying escape sequences. If you want to output a newline you print "\n", a tab is "\t", an alert is "\a", etc, etc...

You can get a complete list on all of the different escape sequences.

To output a slash, you can write, as kurt mentioned:
print "This is one slash: \\ ... \nThis is two slashes: \\\\"

Escape sequences can also be used to output an apostraphe without closing your print statement:
print "Look! An apostraphe: \" ... And yet this is still printed out!"
print 'Another apostraphe: \' ... More text'
Sane is offline   Reply With Quote