[Python-bugs-list] [ python-Bugs-594063 ] r'\' => Syntax error

noreply@sourceforge.net noreply@sourceforge.net
Mon, 12 Aug 2002 08:26:17 -0700


Bugs item #594063, was opened at 2002-08-12 10:32
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=594063&group_id=5470

Category: Parser/Compiler
>Group: Not a Bug
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: a.hofkamp (axhlkhb)
Assigned to: Nobody/Anonymous (nobody)
Summary: r'\' => Syntax error

Initial Comment:
The raw string is supposed to treat \ as literal
characters. It does that with

>>> print r'\aslkjv'
\aslkjv

and

>>> print r'\'kdsr'
\'kdsr

but not with

>>> print r'\'
  File "<stdin>", line 1
    print r'\'
             ^
SyntaxError: invalid token

In the last case, I intend to have a string containing
a \ only.

This happens with Python 1.5.2 and 2.1.1
(on FreeBSD and/or Linux)


----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-08-12 11:26

Message:
Logged In: YES 
user_id=31435

Sorry, you're out of luck -- raw strings can't end with an odd 
number of backslashes, else there would be no way to write 
a raw string containing the quoting character.  See FAQ 
entry 6.29:

<http://www.python.org/cgi-bin/faqw.py?
req=show&file=faq06.029.htp>

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=594063&group_id=5470