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
gh-55688: Add note about ending backslashes for raw strings #94768
base: main
Are you sure you want to change the base?
Conversation
@@ -189,6 +189,29 @@ the first quote:: | |||
>>> print(r'C:\some\name') # note the r before the quote | |||
C:\some\name | |||
|
|||
There is one subtle aspect to raw strings: a raw string may not end in an odd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text of the addition is fine. But I am wondering whether such a subtle point should be part of the introduction.rst
. Perhaps keep only the first line and refer to a location with details?
(not sure what would be a better location)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not strictly a part of this file, see https://docs.python.org/3/reference/lexical_analysis.html:
... even a raw string cannot end in an odd number of backslashes ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text you added in this PR will end up here: https://docs.python.org/3/tutorial/introduction.html#strings right?
It is an informal introduction, so I would write something like:
There is one subtle aspect to raw strings: a raw string may not end in an odd
number of \
characters. For details see String and Bytes literals
But the text added is correct, so it is mostly a matter of style.
https://docs.python.org/3/tutorial/introduction.html
Co-authored-by: R. David Murray rdmurray@bitdance.com