Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-11479: Added a discussion of trailing backslash in raw string to tutorial#27949

Closed
dancinglightning wants to merge 6 commits into
python:mainpython/cpython:mainfrom
dancinglightning:maindancinglightning/cpython:mainCopy head branch name to clipboard
Closed

bpo-11479: Added a discussion of trailing backslash in raw string to tutorial#27949
dancinglightning wants to merge 6 commits into
python:mainpython/cpython:mainfrom
dancinglightning:maindancinglightning/cpython:mainCopy head branch name to clipboard

Conversation

@dancinglightning

@dancinglightning dancinglightning commented Aug 25, 2021

Copy link
Copy Markdown

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@dancinglightning

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!


Another is to add a blank character before the quote and then remove it::

>>> fn = r'C:\this\will\work\ '.strip()

@Julian Julian Aug 25, 2021

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I wouldn't mention this one -- it adds a runtime cost if it's inside some loop or function call, which on its own isn't a huge deal, but it also means you get unexpected behavior if you don't fully realize what this does and try it on r' foo bar \ baz quux\ .

I'd personally leave things with the last workaround (and not mention there are multiple), but if another workaround is desired, using two string literals with the terminal slash in a second one implicitly concatenated is the next-best-one to me:

fn = r'C:\this\will\work' '\\'

@dancinglightning dancinglightning Aug 25, 2021

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I do agree it adds to the runtime but I am pretty sure that this piece of information can be invaluable and many times go unnoticed. I too faced difficulty in comprehending the issue when I got stuck with it. I was able to resolve it later by reading various discussions.

Comment thread Doc/tutorial/introduction.rst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.