Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 7th, 2006, 9:18 AM   #1
b1g4L
Programmer
 
Join Date: Dec 2005
Location: SC
Posts: 38
Rep Power: 0 b1g4L is on a distinguished road
Send a message via AIM to b1g4L
\ 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"
b1g4L is offline   Reply With Quote
Old Dec 7th, 2006, 9:30 AM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Use "\\". That will give you a single, literal backslash.
Arevos is offline   Reply With Quote
Old Dec 7th, 2006, 9:32 AM   #3
b1g4L
Programmer
 
Join Date: Dec 2005
Location: SC
Posts: 38
Rep Power: 0 b1g4L is on a distinguished road
Send a message via AIM to b1g4L
Thanks so much!
b1g4L is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading character input into an array (raw mode) shoeyfighter C 3 Nov 2nd, 2006 3:49 PM
incrementing character array elements value n00b C++ 7 Jun 24th, 2006 3:44 AM
character escape code question angry_asian Java 2 Jun 19th, 2006 6:28 PM
generating character sequence Gumby Java 12 Jun 14th, 2006 7:46 AM
Printing escape sequences using printf()? bivhitscar C 5 Nov 3rd, 2005 10:08 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:32 AM.

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