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
raw byte strings are described in a confusing way #57953
Comments
The lexical analysis documentation says this: http://docs.python.org/py3k/reference/lexical_analysis.html?highlight=raw%20bytes "Bytes literals are always prefixed with 'b' or 'B';..." "Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R';..." But that would lead you to believe that to get raw byte strings you should use rb"foo". In fact, that's a SyntaxError in Python 2.6+ and Python 3. What *does* work though is br"foo". Either Python should accept both spellings (harder) or the documentation should make it clear that the 'b' must preceded the 'r'. |
+1. Been annoyed several times by this. |
On Jan 09, 2012, at 03:15 PM, Antoine Pitrou wrote:
The $64k question: is this a new feature or a bug? :) |
Most certainly a feature... |
On Jan 09, 2012, at 03:35 PM, Antoine Pitrou wrote:
In that case, since we can only add the new prefixes to 3.3, I still think we |
The attached replaces the text for the documentation in 2.4.1 between the lexical definitions table and the escape sequence table. The only change is the following addition to the paragraph on string and byte literals prefixed by 'r' or 'R': When a byte literal is prefixed with both 'r' or 'R' and 'b' or 'B', the b must precede the r, as in: 'Br', 'bR', or 'BR' and not 'Rb', 'rB', or 'RB'. |
I uploaded before making the final save, so the first document is incomplete. (that's embarrassing) |
Thanks for the contribution. Could you post your suggested wording as a plain text file? |
Actually it’s fine, we already have the text in your message :) |
3.3 is now released with both "br" and "rb" allowed, and in 2.7 the current text looks good enough for me. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: