what is wrong with that r"\"

Nick Craig-Wood nick at craig-wood.com
Wed Jul 4 11:30:04 CEST 2007


kyosohma at gmail.com <kyosohma at gmail.com> wrote:
>  On Jul 3, 7:15 am, alf <ask at me> wrote:
> > question without words:
> >
> >  >>> r"\"
> >    File "<stdin>", line 1
> >      r"\"
> >         ^
> > SyntaxError: EOL while scanning single-quoted string
> >  >>> r"\ "
> > '\\ '
> 
>  One slash escapes the following character, so the proper way of
>  writing it is either
> 
>  r"\\" or r"\""

I don't think so...

  >>> r"\\"
  '\\\\'
  >>> r"\""
  '\\"'

Indicating that all the \ in the above are inserted literally.

Maybe you meant

  >>> "\\"
  '\\'
  >>> "\""
  '"'

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list