[issue1271] Raw string parsing fails with backslash as last character
report at bugs.python.org
Sat Mar 12 13:36:59 CET 2011
Graham Wideman <initcontact at grahamwideman.com> added the comment:
Thanks to all for your patient comments. I think I am resigned to raw-string forever being medium-rare-string :-).
Perhaps it's obvious once you get over the initial shock of non-rawness, but workarounds for the disallowed trailing backslash include (note the final space character):
mydir = r"C:\somedir\ ".rstrip() or...
mydir = r"C:\somedir\ "[:-1]
It might be worth mentioning one of these in the raw string docs to emphasize that there is this gotcha, that it's easy to fix, and prompting this as an idiom that becomes familiar in applications where it's needed.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list