Raw string fu

Raw string fu

Post by Joshua Gin » Fri, 28 Oct 2005 03:09:27


>>> r'\'
File "<stdin>", line 1
r'\'
^
SyntaxError: EOL while scanning single-quoted string
'\\\\'

Does that seem wrong to anybody else? Shouldn't the first one be
syntactically correct?

-jag
 
 
 

Raw string fu

Post by Jaime Wyan » Fri, 28 Oct 2005 03:21:24

This URL has a good section on raw strings.

http://www.yqcomputer.com/

r'\' is wrong because raw strings were originally added to make
regular expressions easier to write. And you can't have a regexp that
ends with \.

Also, you can use the \ to escape your original quote character.

"I can\\'t end strings with a \\'"

hth
jw

 
 
 

Raw string fu

Post by Jaime Wyan » Fri, 28 Oct 2005 03:23:23

Doh. that example was supposed to be ->
"I can\\'t end strings with a \\."
 
 
 

Raw string fu

Post by Fredrik Lu » Fri, 28 Oct 2005 03:42:43


the "r" prefix doesn't change how string literals are parsed; it only affects
how they are converted to string objects.

</F>
 
 
 

Raw string fu

Post by Paul McGui » Fri, 28 Oct 2005 04:27:53

"Raw string fu"? A new martial art?
 
 
 

Raw string fu

Post by 'Dang' Dan » Tue, 22 Nov 2005 23:01:14

On 26 Oct 2005 12:27:53 -0700, "Paul McGuire" < XXXX@XXXXX.COM >


For the udon-aware.
--dang