r prefix bug ... or my lack of understanding?

Terry Reedy tjreedy at udel.edu
Wed Jan 28 21:03:05 CET 2004


"Bill Sneddon" <bsneddonNOspam at yahoo.com> wrote in message
news:bv8gtj$5ob$1 at ngspool-d02.news.aol.com...
> Below is from python 2.3.3 on windows.
> I have tryed on Pythonwin and Idle and on
> a Solaris unix build 2.2.2.
>
> I know there are work arounds but the behavior
> seems a bit strange to me.
>
>  >>> path = r'c:\data'   #this is fine
>  >>> print path
> c:\data
>
>  >>> path = r'c:\data\'
> Traceback (  File "<interactive input>", line 1
>      path = r'c:\data\'
>                       ^
> SyntaxError: EOL while scanning single-quoted string
>
>  >>> path = r'c:\data\\'
>  >>> print path
> c:\data\\

Behaves as per manual.

Note: for almost all usages, even on windows, normal Unix-style forward
slashes works as directory terminators and avoids backslash problems
entirely.

path = 'C:/data/'

Terry J. Reedy







More information about the Python-list mailing list