Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   \ as a character, not escape sequence (http://www.programmingforums.org/showthread.php?t=12123)

b1g4L Dec 7th, 2006 10:18 AM

\ as a character, not escape sequence
 
I am parsing a text file and during the process I need to check for a '\'. Python of course thinks I am trying to use the escape sequence. Any way around this?

Here is some example code:

:

if self.data[index] == '\':
  print "Detected a backslash"


Arevos Dec 7th, 2006 10:30 AM

Use "\\". That will give you a single, literal backslash.

b1g4L Dec 7th, 2006 10:32 AM

Thanks so much!


All times are GMT -5. The time now is 1:30 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC