W. eWatson wrote:
What am I missing here? Looks OK to me.
 >>> abc.replace(r'\',r'z')
        
SyntaxError: invalid syntax

A raw string can't end in a single backslash (something that occasionally annoys me, but I've learned to deal with it).

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


My guess is that the parser sees the first call as

  abc.replace(
    r"r\'r"    <-- how your single-quoted is interpreted
    z'         <-- the leftovers that cause the syntax error
    )


-tkc



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to