Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add this to the explanation in "https://github.com/satwikkansal/wtfpython#-backslashes-at-the-end-of-string" #69

Closed
shashank1094 opened this issue Feb 8, 2018 · 3 comments
Milestone

Comments

@shashank1094
Copy link

shashank1094 commented Feb 8, 2018

From SO post - https://stackoverflow.com/questions/647769/why-cant-pythons-raw-string-literals-end-with-a-single-backslash

String quotes can be escaped with a backslash, but the backslash remains in the string; for example, r""" is a valid string literal consisting of two characters: a backslash and a double 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). Note also that a single backslash followed by a newline is interpreted as those two characters as part of the string, not as a line continuation.

Few examples :

>>> print(r"\"")
\"
>>> print(r"A\nB")
A\nB
>>> print(r"A\\nB")
A\\nB
>>> print("A\nB")
A
B
>>> print("A\\nB")
A\nB
>>> print("A\\\nB")
A\
B
@ashish4321
Copy link

Can i work on it?

@ashish4321
Copy link

Are you active??

@satwikkansal satwikkansal added this to the 3.0 milestone May 1, 2019
satwikkansal added a commit that referenced this issue Jun 7, 2019
@satwikkansal
Copy link
Owner

Updated the explanation, thanks @shashank1094 :) You can check the above commit and let me know if something's incorrect / missing.

satwikkansal added a commit that referenced this issue Oct 28, 2019
muscliary pushed a commit to muscliary/wtfpython that referenced this issue Sep 12, 2023
muscliary pushed a commit to muscliary/wtfpython that referenced this issue Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants