Take the 2-minute tour ×  in python, given a variable which
holds a string is there a quick way to cast that into another
raw string variable?  the following code should illustrate what
im after...  def checkEqual(x, y):     print True if x==y else
False  line1 = "hurr..\n..durr" line2 = r"hurr..\n..durr" line3
= "%r"%line1  print "%s \n\n%s \n\n%s \n" % (line1, line2,
line3)  checkEqual(line2, line3)        #outputs False
checkEqual(line2, line3[1:-1])  #outputs True  The closest I
have found so far is the %r formatting flag which seems to
return a raw string albeit within single quote marks. Is there
any easier way to do this like a line3 = raw(line1) kind of
thing?  share|improve this question Please don't use the word
"cast". Python doesn't have such a thing. You want to
"transform" or "convert" a raw string into another string.
"quick" has nothing to do with it either. –  S.Lott Mar 11 '10
at 20:05 checkEqual can simply be return x == y –  Schoolboy Aug
29 '13 at 5:39 Thanks @Schoolboy for pointing that