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

James Henderson james at logicalprogression.net
Wed Jan 28 09:44:34 EST 2004


On Wednesday 28 January 2004 2:27 pm, Bill Sneddon wrote:
> 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\\

Fuether to my last post the full details are at:

http://www.python.org/doc/current/ref/strings.html

>From which I quote:

r"\" is not a valid string literal (even a raw string cannot end in an odd 
number of backslashes). Specifically, a raw string cannot end in a single 
backslash (since the backslash would escape the following quote character)

J.
-- 
James Henderson, Logical Progression Ltd.
http://www.logicalprogression.net/
http://sourceforge.net/projects/mailmanager/





More information about the Python-list mailing list