Skip to content

Is this doc wording about raw bytes literal correct? #122701

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

Closed
sobolevn opened this issue Aug 5, 2024 · 1 comment
Closed

Is this doc wording about raw bytes literal correct? #122701

sobolevn opened this issue Aug 5, 2024 · 1 comment
Assignees
Labels
docs Documentation in the Doc dir

Comments

@sobolevn
Copy link
Member

sobolevn commented Aug 5, 2024

Link: https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

Снимок экрана 2024-08-05 в 21 38 55

Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings

I don't think that it is a correct wording. You cannot call rb'' as a "raw string", it is called "raw bytes". Or "raw bytes literal". Just like the docs docs in the next paragraph:

The 'rb' prefix of raw bytes literals has been added as a synonym of 'br'.

I propose to fix this by using this phrase:

Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R'; such objects are called raw strings and raw bytes respectively.

Linked PRs

@sobolevn sobolevn added the docs Documentation in the Doc dir label Aug 5, 2024
@sobolevn sobolevn self-assigned this Aug 5, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Aug 5, 2024
@terryjreedy
Copy link
Member

I don't think 'raw bytes' is really correct. It is equivalent to 'raw strs', which also strikes me as wrong. 'Raw' applies to the interpretation of the code literal, not to the resulting Python object.. I believe the sentence in question dates back to 2.6 or 2.7 (git blame would tell). The second 'string' is more generic than the first, encompassing both text and bytes literals (code strings defining sequences of internal character-like sequences). Do you have evidence that some people are really confused? I am not sure how to make the point better.

Side note: we have mostly stripped 2.x references from the doc. The last sentence says that in the first sentence, 'literals' means (should be) 'literals without a u/U prefix'.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 11, 2024
…s.rst` (pythonGH-122702)

(cherry picked from commit ea70439)

Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 11, 2024
…s.rst` (pythonGH-122702)

(cherry picked from commit ea70439)

Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
AA-Turner added a commit that referenced this issue Aug 11, 2024
…is.rst` (GH-122702) (#122915)

gh-122701: Fix wording of raw strings/bytes in `lexical_analysis.rst` (GH-122702)
(cherry picked from commit ea70439)

Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
AA-Turner added a commit that referenced this issue Aug 11, 2024
…is.rst` (GH-122702) (#122914)

gh-122701: Fix wording of raw strings/bytes in `lexical_analysis.rst` (GH-122702)
(cherry picked from commit ea70439)

Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
blhsing pushed a commit to blhsing/cpython that referenced this issue Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

2 participants