Bugs item #1530012, was opened at 2006-07-27 15:08
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1530012&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: brucepeterson (brucepeterson)
Assigned to: Nobody/Anonymous (nobody)
Summary: Literal strings use BS as octal escape character

Initial Comment:
Also in 2.4


  Using a literal to hard code a path.  My directory 
happened to start with a number and I couldn't open 
the file due to the bad directory name.  Found that 
the tripple quote was operating as documented.

  I would have at least expected the tripple double 
quotes to not have an escape character.  (Is this a 
pep?)  (From my reading of the Introduction, the 
triple double quotes should act like a raw string 
except that you can have a single double quote 
included in the string.)

-------------
code snippet:
-------------
dir1 = """C:\1stDirecotry"""
dir2 = '''C:\2ndDirecotry'''
dir3 = '''C:\9thDirecotry'''
print dir1, dir2, dir3

C:☺stDirecotry C:☻ndDirecotry C:\9thDirecotry

dir1's format was not expected, dir2's format might be 
expected.

>>> '''\1'''
'\x01'
>>> '''\9'''
'\\9'

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

>Comment By: Neal Norwitz (nnorwitz)
Date: 2006-07-28 20:25

Message:
Logged In: YES 
user_id=33168

Triple quotes are just like single or double quotes wrt
escaping.  You need to prefix the string with an r: 
r"C:\1stDirecotry" to get what you want.

This is probably documented in many places.  I'm not sure
where you looked or where you expected it to be documented.
 Can you suggest improvements?

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1530012&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to