[issue13744] raw byte strings are described in a confusing way

New submission from Barry A. Warsaw <barry@python.org>: The lexical analysis documentation says this: http://docs.python.org/py3k/reference/lexical_analysis.html?highlight=raw%20... "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'. ---------- assignee: docs@python components: Documentation messages: 150936 nosy: barry, docs@python priority: normal severity: normal status: open title: raw byte strings are described in a confusing way versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Antoine Pitrou <pitrou@free.fr> added the comment:
Either Python should accept both spellings
+1. Been annoyed several times by this. ---------- nosy: +gvanrossum, pitrou _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Barry A. Warsaw <barry@python.org> added the comment: On Jan 09, 2012, at 03:15 PM, Antoine Pitrou wrote:
Antoine Pitrou <pitrou@free.fr> added the comment:
Either Python should accept both spellings
+1. Been annoyed several times by this.
The $64k question: is this a new feature or a bug? :) ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Antoine Pitrou <pitrou@free.fr> added the comment:
The $64k question: is this a new feature or a bug? :)
Most certainly a feature... ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Barry A. Warsaw <barry@python.org> added the comment: On Jan 09, 2012, at 03:35 PM, Antoine Pitrou wrote:
Antoine Pitrou <pitrou@free.fr> added the comment:
The $64k question: is this a new feature or a bug? :)
Most certainly a feature...
In that case, since we can only add the new prefixes to 3.3, I still think we need to fix the documentation to remove the confusion for stable releases. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Changes by Terry J. Reedy <tjreedy@udel.edu>: ---------- nosy: +terry.reedy versions: -Python 3.1 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Joseph Chadwick <josephholyheart@gmail.com> added the comment: 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'. ---------- nosy: +j.chadwick type: -> enhancement Added file: http://bugs.python.org/file25064/stringByteLiteralBR.docx _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Joseph Chadwick <josephholyheart@gmail.com> added the comment: I uploaded before making the final save, so the first document is incomplete. (that's embarrassing) ---------- Added file: http://bugs.python.org/file25065/stringByteLiteralBR.docx _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Changes by Martin v. Löwis <martin@v.loewis.de>: Removed file: http://bugs.python.org/file25064/stringByteLiteralBR.docx _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Éric Araujo <merwok@netwok.org> added the comment: Thanks for the contribution. Could you post your suggested wording as a plain text file? ---------- nosy: +eric.araujo _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Éric Araujo <merwok@netwok.org> added the comment: Actually it’s fine, we already have the text in your message :) ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________

Georg Brandl added the comment: 3.3 is now released with both "br" and "rb" allowed, and in 2.7 the current text looks good enough for me. ---------- nosy: +georg.brandl resolution: -> out of date status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13744> _______________________________________
participants (7)
-
Antoine Pitrou
-
Barry A. Warsaw
-
Georg Brandl
-
Joseph Chadwick
-
Martin v. Löwis
-
Terry J. Reedy
-
Éric Araujo